private void OnNetworkStatusChanged(object sender) { var handler = NetworkStatusChanged; if (handler != null) { var args = new NetworkStatusChangedEvents { IsOnline = IsOnline, NetworkType = NetworkType }; handler.Invoke(this, args); } }
private async void OnNetworkStatusChanged(object sender, NetworkStatusChangedEvents e) { using (await _networkMutex.LockAsync()) { // It's safe to await while the lock is held if (e.IsOnline && e.NetworkType == NetworkType.Wifi) { await ResumeAllDownloadsAsync(); } else { await PauseAllDownloadsAsync(); } } }