Exemple #1
0
            public void Dispose()
            {
                this.AssertIsForeground();

                _disposed = true;

                // Stop listening to diagnostic changes from the diagnostic service.
                _owner._diagnosticService.DiagnosticsUpdated -= OnDiagnosticsUpdated;

                // Disconnect us from our underlying taggers and make sure they're
                // released as well.
                foreach (var kvp in _idToProviderAndTagger)
                {
                    var tagger = kvp.Value.Item2;

                    tagger.TagsChanged -= OnUnderlyingTaggerTagsChanged;
                    var disposable = tagger as IDisposable;
                    if (disposable != null)
                    {
                        disposable.Dispose();
                    }
                }

                _idToProviderAndTagger.Clear();
                _owner.RemoveTagger(this, _subjectBuffer);
            }
            public void Dispose()
            {
                this.AssertIsForeground();
                Debug.Assert(_refCount > 0);
                Debug.Assert(!_disposed);

                _refCount--;

                if (_refCount == 0)
                {
                    _disposed = true;

                    // Stop listening to diagnostic changes from the diagnostic service.
                    _owner._diagnosticService.DiagnosticsUpdated -= OnDiagnosticsUpdated;
                    _initialDiagnosticsCancellationSource.Cancel();

                    // Disconnect us from our underlying taggers and make sure they're
                    // released as well.
                    foreach (var kvp in _idToProviderAndTagger)
                    {
                        var tagger = kvp.Value.Item2;

                        DisconnectFromTagger(tagger);
                    }

                    _idToProviderAndTagger.Clear();
                    _owner.RemoveTagger(this, _subjectBuffer);
                }
            }