private void ShowNuGetWarning(ProgressControllerResult executionResult) { if (executionResult == ProgressControllerResult.Succeeded && this.settings.ShowServerNuGetTrustWarning) { this.host.ActiveSection?.UserNotifications?.ShowNotificationWarning(Strings.ServerNuGetTrustWarningMessage, NotificationIds.WarnServerTrustId, this.DontWarnAgainCommand); } }
public void InvokeFinished(ProgressControllerResult result) { if (this.Finished != null) { this.Finished(this, new ProgressControllerFinishedEventArgs(result)); } }
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(); } }); }
/// <summary> /// Starts executing the initialized steps. /// The method is not thread safe but can be called from any thread. /// </summary> /// <returns>An await-able</returns> public async TPL.Task <ProgressControllerResult> Start() { if (this.IsStarted) { throw new InvalidOperationException(ProgressResources.AlreadyStartedException); } this.OnStarted(); ProgressControllerResult controllerResult = await VsThreadingHelper.RunTask <ProgressControllerResult>(this, VsTaskRunContext.BackgroundThread, () => { ThreadHelper.ThrowIfOnUIThread(); // By default can abort, the individual step may changed that this.CanAbort = true; ProgressControllerResult result = ProgressControllerResult.Cancelled; foreach (IProgressStepOperation operation in this.progressStepOperations) { // Try to cancel (in case the step itself will not cancel itself) if (this.cancellationTokenSource.IsCancellationRequested) { result = ProgressControllerResult.Cancelled; break; } this.CanAbort = operation.Step.Cancellable; IProgressStepExecutionEvents notifier = this.stepFactory.GetExecutionCallback(operation); // Give another try before running the operation (there's a test that covers cancellation // before running the operation which requires this check after CanAbort is set) if (this.cancellationTokenSource.IsCancellationRequested) { result = ProgressControllerResult.Cancelled; break; } StepExecutionState stepResult = operation.Run(this.cancellationTokenSource.Token, notifier).Result; /* Not trying to cancel here intentionally. The reason being * in case the step was the last one, there's nothing to cancel really, * otherwise there will be an attempt to cancel just before the next * step execution*/ if (stepResult == StepExecutionState.Succeeded) { result = ProgressControllerResult.Succeeded; } else if (stepResult == StepExecutionState.Failed) { result = ProgressControllerResult.Failed; break; } else if (stepResult == StepExecutionState.Cancelled) { result = ProgressControllerResult.Cancelled; break; } else { Debug.Fail("Unexpected step execution result:" + stepResult); } } return(result); }, this.cancellationTokenSource.Token); this.OnFinished(controllerResult); return(controllerResult); }
public ProgressControllerFinishedEventArgs(ProgressControllerResult result) { this.Result = result; }
public void AssertCorrectExecution(ProgressControllerResult result) { this.started.Should().BeTrue("Invalid execution: Started didn't fire"); this.executionResult.Should().Be(result, "Invalid execution: Finished didn't fire with the expect result ({0})", this.executionResult.HasValue ? this.executionResult.Value.ToString() : "NONE"); }
public void AssertCorrectExecution(ProgressControllerResult result) { Assert.IsTrue(this.started, "Invalid execution: Started didn't fire"); Assert.AreEqual(result, this.executionResult, "Invalid execution: Finished didn't fire with the expect result ({0})", this.executionResult.HasValue ? this.executionResult.Value.ToString() : "NONE"); }
public void SimulateFinished(ProgressControllerResult result) { this.Finished?.Invoke(this, new ProgressControllerFinishedEventArgs(result)); }