private void OnNotificationReceived(object sender, WLAN_NOTIFICATION_DATA e) { Debug.WriteLine($"NotificationReceived: {(WLAN_NOTIFICATION_ACM)e.NotificationCode}"); switch ((WLAN_NOTIFICATION_ACM)e.NotificationCode) { case WLAN_NOTIFICATION_ACM.wlan_notification_acm_scan_list_refresh: NetworkRefreshed?.Invoke(this, EventArgs.Empty); break; case WLAN_NOTIFICATION_ACM.wlan_notification_acm_network_available: case WLAN_NOTIFICATION_ACM.wlan_notification_acm_network_not_available: case WLAN_NOTIFICATION_ACM.wlan_notification_acm_start: case WLAN_NOTIFICATION_ACM.wlan_notification_acm_end: AvailabilityChanged?.Invoke(this, EventArgs.Empty); break; case WLAN_NOTIFICATION_ACM.wlan_notification_acm_interface_arrival: case WLAN_NOTIFICATION_ACM.wlan_notification_acm_interface_removal: InterfaceChanged?.Invoke(this, EventArgs.Empty); break; case WLAN_NOTIFICATION_ACM.wlan_notification_acm_connection_complete: case WLAN_NOTIFICATION_ACM.wlan_notification_acm_disconnected: ConnectionChanged?.Invoke(this, EventArgs.Empty); break; case WLAN_NOTIFICATION_ACM.wlan_notification_acm_profile_change: case WLAN_NOTIFICATION_ACM.wlan_notification_acm_profile_name_change: ProfileChanged?.Invoke(this, EventArgs.Empty); break; } }
/* ----------------------------------------------------------------- */ /// /// WhenChanged /// /// <summary> /// ネットワークの利用可能状況が変化した時に実行されるハンドラです。 /// </summary> /// /// <remarks> /// IsAvailable が true に変化した直後は、実際にはまだ通信可能な /// 状態になっていない事があります。Network クラスでは、 /// IsAvailable が true になってからいずれかのネットワーク /// インターフェースの状態が Up になるまで、最大 2 分の待機時間を /// 設けています。 /// </remarks> /// /* ----------------------------------------------------------------- */ private static void WhenChanged(object s, NetworkAvailabilityEventArgs e) { if (!e.IsAvailable) { AvailabilityChanged?.Invoke(s, e); } else { Task.Run(async() => { var type = typeof(Network); for (var i = 0; i < 24; ++i) // 5 sec * 24 = 2 min { if (Status == OperationalStatus.Up) { Logger.Debug(type, ($"Status:Up ({i * 5} sec)")); AvailabilityChanged?.Invoke(s, e); return; } await Task.Delay(TimeSpan.FromSeconds(5)).ConfigureAwait(false); } Logger.Debug(type, $"Status:{Status} (Timeout)"); AvailabilityChanged?.Invoke(s, e); }).Forget(); } }
public NetworkAvailableService() { Helper = new NetworkAvailableHelper(); Helper.AvailabilityChanged += (e) => AvailabilityChanged?.Invoke(this, new AvailabilityChangedEventArgs { ConnectionType = e }); }
public async Task ChangeMetamaskAvailableAsync(bool available) { Available = available; if (AvailabilityChanged != null) { await AvailabilityChanged.Invoke(available); } }
public async Task ScanNetworkAsync(TimeSpan timeout) { // Netsh has no function to directly prompt to scan wireless LANs. await DeferAsync(() => { NetworkRefreshed?.Invoke(this, EventArgs.Empty); AvailabilityChanged?.Invoke(this, EventArgs.Empty); InterfaceChanged?.Invoke(this, EventArgs.Empty); }); }
public async Task ScanNetworkAsync(TimeSpan timeout) { await Task.Delay(TimeSpan.FromSeconds(1)); // Dummy deferTask = DeferAsync(() => { NetworkRefreshed?.Invoke(this, EventArgs.Empty); AvailabilityChanged?.Invoke(this, EventArgs.Empty); InterfaceChanged?.Invoke(this, EventArgs.Empty); }); }
private async void NotifyAvailabilityChanged(bool available) { logger.WriteLine($"available: {available}"); if (!available) { NotifyAdapterStatusChanged(false); } if (AvailabilityChanged != null) { var data = new AvailabilityChangedEvent { Available = available, AdapterId = "adapterId" }; await dispatcher.RunAsync(CoreDispatcherPriority.Normal, new DispatchedHandler(() => { AvailabilityChanged?.Invoke(this, data); })); } }
private void SetAvailability(bool state, Func <string> messageFunc) { if (_isAvailable != state) { _isAvailable = state; AvailabilityChanged?.Invoke(null, new AvailabilityEventArgs(state, messageFunc?.Invoke())); } if (state) { _tmrChecker.Interval = _successfulCheckingInterval; } else { if (_tmrChecker.Interval >= _successfulCheckingInterval - 1000) { _tmrChecker.Interval = 1000; } else if (_tmrChecker.Interval < _successfulCheckingInterval / 2) { _tmrChecker.Interval += 5000; } } }
protected void RiseAvailabilityChangedEvent(EventArgs args) { AvailabilityChanged?.Invoke(this, args); }
public void SetAvailability(bool isAvailable) { AvailabilityChanged?.Invoke(this, new AvailabilityChangedEventArgs { Book = this, IsAvailable = isAvailable }); }
public void OnAvailabilityChanged(ScannerAvailability args) { AvailabilityChanged?.Invoke(this, args); }
public void OnEvent(AvailabilityChanged e) { AvailibilityChangeEventCount++; }