I am trying to scan the WiFi access points around me to scan their signal strengths. When I use ManagedNativeWifi Nuget (https://github.com/emoacht/ManagedNativeWifi) I can enumerate all Wifi access points:
foreach (var network in NativeWifi.EnumerateBssNetworks())
{
this.textBox1.Text += $"{{Interface: {network.Interface.Description} ({network.Interface.Id})" + Environment.NewLine;
this.textBox1.Text += $" SSID: {network.Ssid}" + Environment.NewLine;
this.textBox1.Text += $" BSS: {network.BssType}" + Environment.NewLine;
this.textBox1.Text += $" BSSID: {network.Bssid}" + Environment.NewLine;
this.textBox1.Text += $" SignalStrength: {network.SignalStrength}" + Environment.NewLine;
this.textBox1.Text += $" LinkQuality: {network.LinkQuality}" + Environment.NewLine;
this.textBox1.Text += $" Frequency: {network.Frequency} KHz" + Environment.NewLine;
this.textBox1.Text += $" Band: {network.Band} GHz" + Environment.NewLine;
this.textBox1.Text += $" Channel: {network.Channel}}}" + Environment.NewLine;
}
But when I try to run this code again, I only get the connected Wifi connection back and all others aren't displayed.
When I try to use this method my application just stops responding.
public static Task RefreshAsync()
{
return NativeWifi.ScanNetworksAsync(timeout: TimeSpan.FromSeconds(10));
}
By calling it from another method
Task task_Refresh = RefreshAsync();
task_Refresh.Wait();
Does anyone know what I am doing wrong? By the way whenever I click the Wifi symbol in the Windows Taskbar it searches all the Wifi networks and above code displays all again.
Sidenote I am using .net Framework 4.7 Windows Forms App.
Best regards and thank you for your time, Rémy Samulski