public DiagnosticProgressReporter( SVsTaskStatusCenterService taskStatusCenterService, IDiagnosticService diagnosticService, VisualStudioWorkspace workspace) { _lastTimeReported = DateTimeOffset.UtcNow; _taskCenterService = (IVsTaskStatusCenterService)taskStatusCenterService; _diagnosticService = diagnosticService; _options = new TaskHandlerOptions() { Title = ServicesVSResources.Live_code_analysis, ActionsAfterCompletion = CompletionActions.None }; var crawlerService = workspace.Services.GetService <ISolutionCrawlerService>(); var reporter = crawlerService.GetProgressReporter(workspace); Started(reporter.InProgress); // no event unsubscription since it will remain alive until VS shutdown reporter.ProgressChanged += OnSolutionCrawlerProgressChanged; _diagnosticService.DiagnosticsUpdated += OnDiagnosticsUpdated; }
public TaskCenterSolutionAnalysisProgressReporter( SVsTaskStatusCenterService taskStatusCenterService, IDiagnosticService diagnosticService, VisualStudioWorkspace workspace) { _lastTimeReported = DateTimeOffset.UtcNow; _resettableDelay = null; ResetProgressStatus(); _taskCenterService = (IVsTaskStatusCenterService)taskStatusCenterService; _options = new TaskHandlerOptions() { Title = ServicesVSResources.Running_low_priority_background_processes, ActionsAfterCompletion = CompletionActions.None }; var crawlerService = workspace.Services.GetService <ISolutionCrawlerService>(); var reporter = crawlerService.GetProgressReporter(workspace); StartedOrStopped(reporter.InProgress); // no event unsubscription since it will remain alive until VS shutdown reporter.ProgressChanged += OnSolutionCrawlerProgressChanged; }
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); }
private static TaskHandlerOptions GetOptions(string title) { var options = new TaskHandlerOptions { Title = title, ActionsAfterCompletion = CompletionActions.None }; return(options); }
private static TaskHandlerOptions GetOptions(string title) { var options = new TaskHandlerOptions { Title = title, RetentionAfterCompletion = CompletionRetention.Faulted }; return(options); }
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); } }
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)); }
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); }
public TaskCenterSolutionAnalysisProgressReporter( SVsTaskStatusCenterService taskStatusCenterService, IDiagnosticService diagnosticService, VisualStudioWorkspace workspace) { _taskCenterService = (IVsTaskStatusCenterService)taskStatusCenterService; _options = new TaskHandlerOptions() { Title = ServicesVSResources.Running_low_priority_background_processes, ActionsAfterCompletion = CompletionActions.None }; var crawlerService = workspace.Services.GetRequiredService <ISolutionCrawlerService>(); var reporter = crawlerService.GetProgressReporter(workspace); if (reporter.InProgress) { // The reporter was already sending events before we were able to subscribe, so trigger an update to the task center. OnSolutionCrawlerProgressChanged(this, new ProgressData(ProgressStatus.Started, pendingItemCount: null)); } reporter.ProgressChanged += OnSolutionCrawlerProgressChanged; }