Пример #1
0
        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()));
            }
        }
Пример #2
0
        private async void RefreshIsCurrentTimer_Elapsed(object state)
        {
            if (_isDisposed)
            {
                return;
            }

            try {
                _refreshIsCurrentTrigger.Change(Timeout.Infinite, Timeout.Infinite);
            } catch (ObjectDisposedException) {
            }

            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 (FileNotFoundException) {
                // Happens if we attempt to refresh an environment that was just deleted
            } catch (Exception ex) when(!ex.IsCriticalException())
            {
                Debug.Fail(ex.ToUnhandledExceptionMessage(GetType()));
            }
        }
Пример #3
0
        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();
        }