예제 #1
0
        public static async Task ProcessLogFileWrapperAsync(string filePath, string toolFormat, bool promptOnLogConversions, bool cleanErrors, bool openInEditor)
        {
            var taskStatusCenterService = (IVsTaskStatusCenterService)Package.GetGlobalService(typeof(SVsTaskStatusCenterService));
            var taskProgressData        = new TaskProgressData
            {
                CanBeCanceled = false,
                ProgressText  = null,
            };

            string fileName = Path.GetFileName(filePath);

            var taskHandlerOptions = new TaskHandlerOptions
            {
                ActionsAfterCompletion = CompletionActions.None,
                TaskSuccessMessage     = string.Format(CultureInfo.CurrentCulture, Resources.CompletedProcessingLogFileFormat, fileName),
                Title = string.Format(CultureInfo.CurrentCulture, Resources.ProcessingLogFileFormat, fileName),
            };

            ITaskHandler taskHandler = taskStatusCenterService.PreRegister(taskHandlerOptions, taskProgressData);

            Task task = ProcessLogFileAsync(filePath, toolFormat, promptOnLogConversions, cleanErrors, openInEditor);

            taskHandler.RegisterTask(task);

            await task.ConfigureAwait(continueOnCapturedContext : false);
        }
예제 #2
0
        private Task OnDownloadFullDatabaseStartedWorkerAsync(string title)
        {
            var options = GetOptions(title);
            var data    = new TaskProgressData
            {
                CanBeCanceled   = false,
                PercentComplete = null,
            };

            TaskCompletionSource <bool> localTaskCompletionSource;

            lock (_gate)
            {
                // Take any existing tasks and move them to the complete state.
                _taskCompletionSource.TrySetResult(true);

                // Now create an existing task to track the current download and let
                // vs know about it.
                _taskCompletionSource     = new TaskCompletionSource <bool>();
                localTaskCompletionSource = _taskCompletionSource;
            }

            var handler = _taskCenterServiceOpt.Value?.PreRegister(options, data);

            handler?.RegisterTask(localTaskCompletionSource.Task);

            return(Task.CompletedTask);
        }
        private async Task LoadSarifLogAsync(IEnumerable <string> paths)
        {
            var validPaths = paths.Where(path => !string.IsNullOrEmpty(path)).ToList();

            if (validPaths.Count == 0)
            {
                return;
            }

            var taskStatusCenterService = (IVsTaskStatusCenterService)Package.GetGlobalService(typeof(SVsTaskStatusCenterService));
            var taskProgressData        = new TaskProgressData
            {
                CanBeCanceled = true,
                ProgressText  = null,
            };

            var taskHandlerOptions = new TaskHandlerOptions
            {
                ActionsAfterCompletion = CompletionActions.None,
                TaskSuccessMessage     = Resources.ProcessLogFilesComplete,
                Title = Resources.ProcessLogFiles,
            };

            var          taskCompletionSource = new TaskCompletionSource <bool>();
            ITaskHandler taskHandler          = taskStatusCenterService.PreRegister(taskHandlerOptions, taskProgressData);

            taskHandler.RegisterTask(taskCompletionSource.Task);

            try
            {
                for (int validPathIndex = 0; validPathIndex < validPaths.Count; validPathIndex++)
                {
                    taskHandler.UserCancellation.ThrowIfCancellationRequested();

                    taskHandler.Progress.Report(new TaskProgressData
                    {
                        PercentComplete = validPathIndex * 100 / validPaths.Count,
                        ProgressText    = string.Format(CultureInfo.CurrentCulture, Resources.ProcessingLogFileFormat, validPaths[validPathIndex]),
                    });

                    // We should not clean errors here. If the user wants to clear errors, they can call ICloseSarifLogService.CloseAllSarifLogs.
                    await ErrorListService.ProcessLogFileAsync(validPaths[validPathIndex], ToolFormat.None, promptOnLogConversions : false, cleanErrors : false, openInEditor : false).ConfigureAwait(continueOnCapturedContext: false);

                    taskHandler.Progress.Report(new TaskProgressData
                    {
                        PercentComplete = (validPathIndex + 1) * 100 / validPaths.Count,
                    });
                }
            }
            finally
            {
                taskCompletionSource.SetResult(true);
            }
        }
예제 #4
0
        private static async Task <ITaskHandler> SetupTaskStatusCenter()
        {
            IVsTaskStatusCenterService tsc =
                await _package.GetServiceAsync(typeof(SVsTaskStatusCenterService)) as IVsTaskStatusCenterService;

            TaskHandlerOptions options = default(TaskHandlerOptions);

            options.Title = Vsix.Name;
            options.DisplayTaskDetails     = task => { Logger.ShowOutputWindowPane(); };
            options.ActionsAfterCompletion = CompletionActions.None;
            TaskProgressData data = default(TaskProgressData);

            data.CanBeCanceled = true;
            return(tsc.PreRegister(options, data));
        }
예제 #5
0
        private static void OnUpdate(object sender, Progress progress)
        {
            TaskProgressData data = new TaskProgressData
            {
                ProgressText    = progress.Text,
                PercentComplete = progress.Percent,
                CanBeCanceled   = true
            };

            _handler.Progress.Report(data);
            if (!_hasShownProgress)
            {
                _hasShownProgress = true;
                VsHelpers.ShowTaskStatusCenter();
            }
        }
        public async Task <ITaskHandler> CreateTaskHandlerAsync(string title)
        {
            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            IVsTaskStatusCenterService taskStatusCenter = (IVsTaskStatusCenterService)Package.GetGlobalService(typeof(SVsTaskStatusCenterService));
            TaskHandlerOptions         options          = default(TaskHandlerOptions);

            options.Title = title;
            options.ActionsAfterCompletion = CompletionActions.None;

            TaskProgressData data = default(TaskProgressData);

            data.CanBeCanceled = true;

            ITaskHandler handler = taskStatusCenter.PreRegister(options, data);

            return(handler);
        }
예제 #7
0
        private void AsyncStartScanInternal()
        {
            try
            {
                var taskStatusCenterService = AsyncPackage.GetGlobalService(typeof(SVsTaskStatusCenterService)) as IVsTaskStatusCenterService;
                if (taskStatusCenterService == null)
                {
                    return;
                }

                var options = default(TaskHandlerOptions);
                options.Title = "Scanning solution for Dpdt clusters and its bindings...";
                options.ActionsAfterCompletion = CompletionActions.None;

                _data = default(TaskProgressData);
                _data.CanBeCanceled = false;

                var handler = taskStatusCenterService.PreRegister(options, _data);


                _backgroundScanner = new BackgroundScanner(
                    _outputPane !,
                    _buildStatusContainer
                    );

                CodeLensConnectionHandler.RefreshAllCodeLensDataPointsAsync()
                .FileAndForget(nameof(CodeLensConnectionHandler.RefreshAllCodeLensDataPointsAsync))
                ;

                _backgroundScanner.AsyncStart();

                handler.RegisterTask(
                    Task.Run(
                        async() => await ShowProgressAsync(handler)
                        )
                    );
            }
            catch (Exception excp)
            {
                LogVS(excp);
            }
        }