private async void checkProgressUpdated(object sender, ICodeAnalyzer.ProgressEvenArgs e)
        {
            int progress = e.Progress;

            if (progress == 0)
            {
                progress = 1;                 // statusBar.Progress won't display a progress bar with 0%
            }
            await JoinableTaskFactory.SwitchToMainThreadAsync();

            EnvDTE.StatusBar statusBar = _dte.StatusBar;
            if (statusBar != null)
            {
                string label = "";
                if (progress < 100)
                {
                    if (e.FilesChecked == 0 || e.TotalFilesNumber == 0)
                    {
                        label = "cppcheck analysis in progress...";
                    }
                    else
                    {
                        label = "cppcheck analysis in progress (" + (completedFileCount + e.FilesChecked) + " out of " + (completedFileCount + e.TotalFilesNumber) + " files checked)";
                    }

                    lastAnalyzerTotalFiles = e.TotalFilesNumber;

                    statusBar.Progress(true, label, progress, 100);
                }
                else
                {
                    label = "cppcheck analysis completed";
                    completedFileCount    += lastAnalyzerTotalFiles;
                    lastAnalyzerTotalFiles = 0;

                    try
                    {
                        // This raises an exception during shutdown.
                        statusBar.Progress(true, label, progress, 100);
                    }
                    catch (Exception) { }

                    _ = System.Threading.Tasks.Task.Run(async delegate
                    {
                        await System.Threading.Tasks.Task.Delay(5000);
                        await JoinableTaskFactory.SwitchToMainThreadAsync();
                        try
                        {
                            statusBar.Progress(false, label, 100, 100);
                        }
                        catch (Exception) { }
                    });

                    setMenuState(false);
                }
            }
        }
Example #2
0
        private void checkProgressUpdated(object sender, ICodeAnalyzer.ProgressEvenArgs e)
        {
            int progress = e.Progress;

            if (progress == 0)
            {
                progress = 1;                 // statusBar.Progress won't display a progress bar with 0%
            }
            EnvDTE.StatusBar statusBar = _dte.StatusBar;
            if (statusBar != null)
            {
                String label = "";
                if (progress < 100)
                {
                    if (e.FilesChecked == 0 || e.TotalFilesNumber == 0)
                    {
                        label = "cppcheck analysis in progress...";
                    }
                    else
                    {
                        label = "cppcheck analysis in progress (" + e.FilesChecked + " out of " + e.TotalFilesNumber + " files checked)";
                    }

                    statusBar.Progress(true, label, progress, 100);
                }
                else
                {
                    label = "cppcheck analysis completed";
                    statusBar.Progress(true, label, progress, 100);
                    System.Threading.Tasks.Task.Run(async delegate
                    {
                        await System.Threading.Tasks.Task.Delay(5000);
                        statusBar.Progress(false, label, 100, 100);
                    });
                }
            }
        }