private async void OnHistoryFileChanged(object sender, EventArgs e) { if (_isDisposed) { return; } InstalledFilesChanged?.Invoke(this, EventArgs.Empty); _factory.NotifyImportNamesChanged(); var cts = new CancellationTokenSource(); var cancellationToken = cts.Token; var oldCts = Interlocked.Exchange(ref _currentRefresh, cts); try { oldCts?.Cancel(); oldCts?.Dispose(); } catch (ObjectDisposedException) { } try { await CacheInstalledPackagesAsync(false, false, cancellationToken); } catch (OperationCanceledException) { } catch (Exception ex) when(!ex.IsCriticalException()) { Debug.Fail(ex.ToUnhandledExceptionMessage(GetType())); } }
private async void RefreshIsCurrentTimer_Elapsed(object state) { if (_isDisposed) { return; } try { _refreshIsCurrentTrigger.Change(Timeout.Infinite, Timeout.Infinite); } catch (ObjectDisposedException) { } InstalledFilesChanged?.Invoke(this, EventArgs.Empty); var cts = new CancellationTokenSource(); var cancellationToken = cts.Token; var oldCts = Interlocked.Exchange(ref _currentRefresh, cts); try { oldCts?.Cancel(); oldCts?.Dispose(); } catch (ObjectDisposedException) { } try { await CacheInstalledPackagesAsync(false, false, cancellationToken); } catch (OperationCanceledException) { } catch (Exception ex) when(!ex.IsCriticalException()) { Debug.Fail(ex.ToUnhandledExceptionMessage(GetType())); } }
private void RefreshIsCurrentTimer_Elapsed(object state) { if (_isDisposed) { return; } InstalledFilesChanged?.Invoke(this, EventArgs.Empty); var cts = new CancellationTokenSource(); var oldCts = Interlocked.Exchange(ref _currentRefresh, cts); oldCts?.Cancel(); oldCts?.Dispose(); CacheInstalledPackagesAsync(false, cts.Token) .SilenceException <OperationCanceledException>() .DoNotWait(); }