private async Task ResetStatesAsync()
                    {
                        try
                        {
                            if (!IsSolutionChanged())
                            {
                                return;
                            }

                            await RunAnalyzersAsync(this.Analyzers, this.Processor.CurrentSolution, (a, s, c) => a.NewSolutionSnapshotAsync(s, c), this.CancellationToken).ConfigureAwait(false);

                            foreach (var id in this.Processor.GetOpenDocumentIds())
                            {
                                AddHigherPriorityDocument(id);
                            }

                            SolutionCrawlerLogger.LogResetStates(this.Processor._logAggregator);
                        }
                        catch (Exception e) when(FatalError.ReportUnlessCanceled(e))
                        {
                            throw ExceptionUtilities.Unreachable;
                        }

                        bool IsSolutionChanged()
                        {
                            var currentSolution = this.Processor.CurrentSolution;
                            var oldSolution     = _lastSolution;

                            if (currentSolution == oldSolution)
                            {
                                return(false);
                            }

                            _lastSolution = currentSolution;

                            ResetLogAggregatorIfNeeded(currentSolution, oldSolution);

                            return(true);
                        }

                        void ResetLogAggregatorIfNeeded(Solution currentSolution, Solution oldSolution)
                        {
                            if (currentSolution == null || oldSolution == null ||
                                currentSolution.Id == oldSolution.Id)
                            {
                                // we log aggregated info when solution is changed such as
                                // new solution is opened or solution is closed
                                return;
                            }

                            // this log things like how many time we analyzed active files, how many times other files are analyzed,
                            // avg time to analyze files, how many solution snapshot got analyzed and etc.
                            // all accumultation is done in VS side and we only send statistics to VS telemetry otherwise, it is too much
                            // data to send
                            SolutionCrawlerLogger.LogIncrementalAnalyzerProcessorStatistics(
                                this.Processor._registration.CorrelationId, oldSolution, this.Processor._logAggregator, this.Analyzers);

                            this.Processor.ResetLogAggregator();
                        }
                    }
                    public override void Shutdown()
                    {
                        base.Shutdown();

                        SolutionCrawlerLogger.LogIncrementalAnalyzerProcessorStatistics(this.Processor._registration.CorrelationId, this.Processor.CurrentSolution, this.Processor._logAggregator, this.Analyzers);

                        _workItemQueue.Dispose();

                        if (_projectCache != null)
                        {
                            _projectCache.Dispose();
                            _projectCache = null;
                        }
                    }