protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);

            if (disposing)
            {
                this.daemon?.Dispose();
                this.daemon = null;
                statusBarDownloadProgressHandler?.Dispose();
                statusBarDownloadProgressHandler = null;
            }
        }
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);

            if (disposing)
            {
                this.daemon?.Dispose();
                this.daemon = null;
                statusBarDownloadProgressHandler?.Dispose();
                statusBarDownloadProgressHandler = null;
                cFamilyPreCompiledHeadersEventListener?.Dispose();
                cFamilyPreCompiledHeadersEventListener = null;
            }
        }
        private async System.Threading.Tasks.Task InitAsync()
        {
            try
            {
                logger = await this.GetMefServiceAsync <ILogger>();

                logger.WriteLine(Resources.Strings.Daemon_Initializing);

                await DisableRuleCommand.InitializeAsync(this, logger);

                await CFamilyReproducerCommand.InitializeAsync(this, logger);

                cFamilyPreCompiledHeadersEventListener = await this.GetMefServiceAsync <IPreCompiledHeadersEventListener>();

                daemon = await this.GetMefServiceAsync <ISonarLintDaemon>();

                LegacyInstallationCleanup.CleanupDaemonFiles(logger);

                // Set up the solution tracker so we can shut down the daemon when a solution is closed
                var solutionTracker = await this.GetMefServiceAsync <IActiveSolutionTracker>();

                solutionTracker.ActiveSolutionChanged += HandleActiveSolutionChanged;

                IDaemonInstaller installer = await this.GetMefServiceAsync <IDaemonInstaller>();

                if (!installer.IsInstalled())
                {
                    // Set up the status bar download handler in case the user enables
                    // support for additional languages during the VS session
                    var sbService = await this.GetServiceAsync(typeof(IVsStatusbar)) as IVsStatusbar;

                    statusBarDownloadProgressHandler = new StatusBarDownloadProgressHandler(sbService, installer, logger);

                    var settings = await this.GetMefServiceAsync <ISonarLintSettings>();

                    if (settings.IsActivateMoreEnabled)
                    {
                        // User already agreed to have the daemon installed so directly start download.
                        // No UI interation so we don't need to be on the UI thread.
                        installer.Install();
                    }
                }
            }
            catch (Exception ex) when(!ErrorHandler.IsCriticalException(ex))
            {
                logger?.WriteLine(Resources.Strings.ERROR_InitializingDaemon, ex);
            }
            logger?.WriteLine(Resources.Strings.Daemon_InitializationComplete);
        }