-2
new Thread(() =>
{
while (true)
{
IList<ScanResult> scanwifinetworks = wifiManager.ScanResults;
foreach (Android.Net.Wifi.ScanResult wifinetwork in scanwifinetworks)
{
try
{
if (wifissid != (wifinetwork.Ssid))
{
wifissid = wifinetwork.Ssid;
lstSource.Add(new Person() { wifi_Rssi = wifinetwork.Level, wifi_ssid = wifissid });
Console.WriteLine(wifi_rssi);
var adapter = new CustomAdapter(this, lstSource);
lstData.Adapter = adapter;
Console.WriteLine(WiFiNetworks);
}
}
catch (Exception)
{
Console.WriteLine("EXscption");
}
Thread.Sleep(2000);
}
}
}).Start();
如果我嘗試做ListView中的任何事情,我可以補充,但是當我嘗試在線程添加它崩潰(lstData.Adapter = adapter;
)。在線程的ListView適配器崩潰xamarin