private static ProgressObserver CreateAndConfigureInstance(IServiceProvider serviceProvider, IProgressVisualizer visualizer, IProgressEvents progressEvents, ICommand cancelCommand, ProgressControllerViewModel state) { return(VsThreadingHelper.RunInline(serviceProvider, VsTaskRunContext.UIThreadNormalPriority, () => { ProgressObserver returnValue = new ProgressObserver(serviceProvider, visualizer, progressEvents, state); returnValue.CancelCommand = cancelCommand; return returnValue; }, null)); }
private void OnCancellationSupportChanged(object sender, CancellationSupportChangedEventArgs e) { VsThreadingHelper.RunInline(this.serviceProvider, VsTaskRunContext.UIThreadNormalPriority, () => { ChangeCancellability(e.Cancellable); }); // Flag that handled to assist with the verification, otherwise the controller will assert e.Handled(); }
/// <summary> /// Stops the specified <see cref="ProgressObserver"/> from observing. /// The method is thread safe. /// </summary> /// <param name="observer">An existing <see cref="ProgressObserver"/> to stop observing with</param> public static void StopObserving(ProgressObserver observer) { if (observer == null) { throw new ArgumentNullException(nameof(observer)); } if (observer.disposed) { return; } VsThreadingHelper.RunInline(observer.serviceProvider, VsTaskRunContext.UIThreadNormalPriority, () => ((IDisposable)observer).Dispose()); }
/// <summary> /// Invokes the <see cref="StateChanged"/> event based on the <see cref="ExecutionState"/> of the object /// </summary> protected virtual void OnExecutionStateChanged() { if (this.StateChangedPrivate != null) { VsThreadingHelper.RunInline(this.controller, VsTaskRunContext.UIThreadBackgroundPriority, () => { var delegates = this.StateChangedPrivate; if (delegates != null) { delegates(this, new StepExecutionChangedEventArgs(this)); } }); } }
void IProgressErrorNotifier.Notify(Exception ex) { if (ex == null) { throw new ArgumentNullException(nameof(ex)); } VsThreadingHelper.RunInline(this.serviceProvider, VsTaskRunContext.UIThreadNormalPriority, () => { int hr = this.pane.OutputStringThreadSafe(ProgressControllerHelper.FormatErrorMessage(ex, this.messageFormat, this.logFullException) + Environment.NewLine); if (this.ensureOutputVisible && ErrorHandler.Succeeded(hr) && ErrorHandler.Succeeded(pane.Activate())) { ShowOutputWindowFrame(serviceProvider); } }); }
private void ControllerFinished(object sender, ProgressControllerFinishedEventArgs e) { this.IsFinished = true; VsThreadingHelper.RunInline(this.serviceProvider, VsTaskRunContext.BackgroundThread, () => { // Give the last progress a chance to render System.Threading.Thread.Sleep(DelayAfterFinishInMS); }); VsThreadingHelper.RunInline(this.serviceProvider, VsTaskRunContext.UIThreadNormalPriority, () => { this.host.Hide(); ((IDisposable)this).Dispose(); }); // Flag that handled to assist with the verification, otherwise the controller will assert e.Handled(); }
private void OnStepStateChanged(object sender, StepExecutionChangedEventArgs args) { if (this.StepExecutionChangedPrivate != null) { VsThreadingHelper.RunInline(this, VsTaskRunContext.UIThreadNormalPriority, () => { var delegates = this.StepExecutionChangedPrivate; if (delegates != null) { delegates(sender, args); // Verify that the observer handled it since now easy way of testing // serialized raising and handling of the event across the classes args.CheckHandled(); } }); } }
private void OnCancellableChanged(bool cancellable) { if (this.CancellationSupportChangedPrivate != null) { VsThreadingHelper.RunInline(this, VsTaskRunContext.UIThreadNormalPriority, () => { var delegates = this.CancellationSupportChangedPrivate; if (delegates != null) { CancellationSupportChangedEventArgs args = new CancellationSupportChangedEventArgs(cancellable); delegates(this, args); // Verify that the observer handled it since now easy way of testing // serialized raising and handling of the event across the classes args.CheckHandled(); } }); } }
void IProgressErrorNotifier.Notify(Exception ex) { if (ex == null) { throw new ArgumentNullException(nameof(ex)); } VsThreadingHelper.RunInline(this.serviceProvider, VsTaskRunContext.UIThreadNormalPriority, () => { IVsActivityLog log = (IVsActivityLog)this.serviceProvider.GetService(typeof(SVsActivityLog)); if (log != null) { log.LogEntry((uint)__ACTIVITYLOG_ENTRYTYPE.ALE_ERROR, this.entrySource, ProgressControllerHelper.FormatErrorMessage(ex, messageFormat, logWholeMessage)); } else { Debug.Fail("Cannot find SVsActivityLog"); } }); }
private void OnFinished(ProgressControllerResult result) { this.IsFinished = true; this.ThreadSafeDisposeCancellationTokenSource(); VsThreadingHelper.RunInline(this, VsTaskRunContext.UIThreadNormalPriority, () => { ConfigureStepEventListeners(false); var delegates = this.FinishedPrivate; if (delegates != null) { ProgressControllerFinishedEventArgs args = new ProgressControllerFinishedEventArgs(result); delegates(this, args); // Verify that the observer handled it since now easy way of testing // serialized raising and handling of the event across the classes args.CheckHandled(); } }); }
private void OnStepExecutionChanged(object sender, StepExecutionChangedEventArgs e) { try { // Don't have to do it on the UI thread since we don't expect the mapping to change during execution if (!this.progressStepToViewModelMapping.ContainsKey(e.Step)) { Debug.Assert(!e.Step.ImpactsProgress, "View model out of sync. The step execution is for unexpected step"); return; } VsThreadingHelper.RunInline(this.serviceProvider, VsTaskRunContext.UIThreadNormalPriority, () => { this.UpdateViewModelStep(e); this.UpdateMainProgress(e); }); } finally { // Flag that handled to assist with the verification, otherwise the controller will assert e.Handled(); } }