async void SetNetWorkAdapterEnabeldAsync() { await Task.Run(new Action(() => { try { if (!IsEnabledWifi) { System.Windows.Application.Current.Dispatcher.Invoke(new Action(() => { if (AccessPointList.Count > 0) { AccessPointList.Clear(); } })); } GetpotentialAdapter(); NetWorkAdapter.SetNetWorkAdapterEnabeld(CurrentWifiAdapter, IsEnabledWifi); CheckWifiIsEnabled(700); } catch (Exception ex) { } finally { IsRunning = false; } })); }
/// <summary> /// 检测wifi开启状态 /// </summary> /// <param name="isEnabledWifi"></param> void CheckWifiIsEnabled(bool isEnabledWifi) { if (isEnabledWifi) { ListAll(); } else { System.Windows.Application.Current.Dispatcher.Invoke(new Action(() => { if (AccessPointList.Count > 0) { AccessPointList.Clear(); } })); } }
/// <summary> /// Tests the sync logic with pre-defined <see cref="AppList"/>s. /// local add: appEntry1, local remove: appEntry2, remote add: appEntry3, remote remove: appEntry4 /// </summary> /// <param name="resetMode">The <see cref="SyncResetMode"/> to pass to <see cref="SyncIntegrationManager.Sync"/>.</param> /// <param name="ap1Applied">The flag file used to indicate that <see cref="MockAccessPoint.Apply"/> was called for appEntry1.</param> /// <param name="ap1NotApplied">The flag file used to indicate that <see cref="MockAccessPoint.Unapply"/> was called for appEntry1.</param> /// <param name="ap2Applied">The flag file used to indicate that <see cref="MockAccessPoint.Apply"/> was called for appEntry2.</param> /// <param name="ap2NotApplied">The flag file used to indicate that <see cref="MockAccessPoint.Unapply"/> was called for appEntry2.</param> /// <param name="ap3Applied">The flag file used to indicate that <see cref="MockAccessPoint.Apply"/> was called for appEntry3.</param> /// <param name="ap3NotApplied">The flag file used to indicate that <see cref="MockAccessPoint.Unapply"/> was called for appEntry3.</param> /// <param name="ap4Applied">The flag file used to indicate that <see cref="MockAccessPoint.Apply"/> was called for appEntry4.</param> /// <param name="ap4NotApplied">The flag file used to indicate that <see cref="MockAccessPoint.Unapply"/> was called for appEntry4.</param> private static void TestSync(SyncResetMode resetMode, TemporaryFlagFile ap1Applied, TemporaryFlagFile ap1NotApplied, TemporaryFlagFile ap2Applied, TemporaryFlagFile ap2NotApplied, TemporaryFlagFile ap3Applied, TemporaryFlagFile ap3NotApplied, TemporaryFlagFile ap4Applied, TemporaryFlagFile ap4NotApplied) { var appEntry1 = new AppEntry { InterfaceUri = FeedTest.Test1Uri, AccessPoints = new AccessPointList { Entries = { new MockAccessPoint { ApplyFlagPath = ap1Applied, UnapplyFlagPath = ap1NotApplied } } } }; var appEntry2 = new AppEntry { InterfaceUri = FeedTest.Test2Uri, AccessPoints = new AccessPointList { Entries = { new MockAccessPoint { ApplyFlagPath = ap2Applied, UnapplyFlagPath = ap2NotApplied } } } }; var appEntry3 = new AppEntry { InterfaceUri = FeedTest.Test3Uri, AccessPoints = new AccessPointList { Entries = { new MockAccessPoint { ApplyFlagPath = ap3Applied, UnapplyFlagPath = ap3NotApplied } } } }; var appEntry4 = new AppEntry { InterfaceUri = new("http://example.com/test4.xml"), AccessPoints = new AccessPointList { Entries = { new MockAccessPoint { ApplyFlagPath = ap4Applied, UnapplyFlagPath = ap4NotApplied } } } }; var appListLocal = new AppList { Entries = { appEntry1, appEntry4 } }; var appListLast = new AppList { Entries = { appEntry2, appEntry4 } }; var appListServer = new AppList { Entries = { appEntry2, appEntry3 } }; TestSync(resetMode, appListLocal, appListLast, appListServer); } #endregion }