public override void ConnectTrueWifi() { connectionStateCallBack.StateChange("连接正确WIFI..."); // 打开WLAN NativeWifi.TurnOnInterfaceRadio(NativeWifi.EnumerateInterfaces().FirstOrDefault().Id); while (true) { // 找到 WIFI var a = NativeWifi.EnumerateAvailableNetworks() .Where(x => !string.IsNullOrWhiteSpace(x.ProfileName)) .OrderByDescending(x => x.SignalQuality) .Where(x => x.Ssid.ToString().Equals("HXGNET")) .FirstOrDefault(); if (a == null) { connectionStateCallBack.StateChange("等待WIFI..."); Thread.Sleep(500); continue; } // 连接 NativeWifi.ConnectNetwork(a.Interface.Id, a.ProfileName, a.BssType); connectionStateCallBack.StateChange("已连接WIFI..."); break; } }