/// <summary> /// Runs an asynchronious operation using a STA thread /// </summary> /// <param name="workerParams"></param> /// <param name="work"></param> /// <param name="completeHandler"></param> public static void RunSTA(ProgressWorkerParams workerParams, Action <IProgressVisualizer> work, Action completeHandler) { if (work == null) { throw new ArgumentNullException("work"); } IProgressVisualizer progressVisualizer = null; AsyncHelper.RunAsyncSTA( operation => { progressVisualizer = (new DefaultProgressService()).CreateVisualizer(workerParams); work(progressVisualizer); }, () => { progressVisualizer.Complete(); if (completeHandler != null) { completeHandler(); } }); Application.DoEvents(); }
public UpdateCliCommand(ITransactionFactory transactionFactory, IExceptionHandler exceptionHandler, ExecutionContext executionContext, ICommandResultVisualizer commandResultVisualizer, ICliUpdater cliUpdater, IFileSystem fileSystem, IProgressVisualizer progressVisualizer, IUserInterface userInterface) : base(transactionFactory, exceptionHandler, executionContext, commandResultVisualizer) { this.cliUpdater = cliUpdater; this.fileSystem = fileSystem; this.progressVisualizer = progressVisualizer; this.userInterface = userInterface; }
private static ProgressObserver Observe(IProgressController controller, IProgressVisualizer visualizer) { ProgressObserver observer = CreateObserver(controller, visualizer, null); observedControllersMap.Add(controller, observer); return(observer); }
public ExecutionVerifier(IProgressVisualizer visualizer, ProgressObserver testSubject) { Assert.IsNotNull(visualizer != null, "IProgressVisualizer is expected"); Assert.IsNotNull(testSubject != null, "ProgressObserver is expected"); this.visualizer = visualizer; this.testSubject = testSubject; }
public ExecutionVerifier(IProgressVisualizer visualizer, ProgressObserver testSubject) { visualizer.Should().NotBeNull(); testSubject.Should().NotBeNull(); this.visualizer = visualizer; this.testSubject = testSubject; }
public IDisposableCommandLineParser BuildCommandLineInstance(IUserInterface userInterface, IProgressVisualizer progressVisualizer, ICommandResultVisualizer commandResultVisualizer, CancellationToken cancellationToken) { ILifetimeScope lifetimeScope = commandLineContainer.LifetimeScope.BeginLifetimeScope( builder => { builder.RegisterInstance(userInterface).As <IUserInterface>().SingleInstance(); builder.RegisterInstance(progressVisualizer).As <IProgressVisualizer>().SingleInstance(); builder.RegisterInstance(commandResultVisualizer).As <ICommandResultVisualizer>().SingleInstance(); builder.Register(_ => cancellationToken).As <CancellationToken>().SingleInstance(); Common.BaseDiModule.AddAutoActivatedComponents(builder); }); return(new DisposableCommandLineParser(lifetimeScope, lifetimeScope.Resolve <ICommandLineParser>())); }
private static void VerifyProgress(IProgressVisualizer visualizer, double mainProgress, ProgressStepViewModel current, double subProgress) { Assert.AreEqual(mainProgress, visualizer.ViewModel.MainProgress.Value, FloatingPointError, "Unexpected main progress"); if (current == null) { Assert.IsNull(visualizer.ViewModel.Current, "Not expecting any current step"); } else { Assert.AreSame(current, visualizer.ViewModel.Current, "Unexpected current step"); if (double.IsNaN(subProgress)) { Assert.IsTrue(double.IsNaN(current.Progress.Value), "Unexpected sub progress"); } else { Assert.AreEqual(subProgress, current.Progress.Value, FloatingPointError, "Unexpected sub progress"); } } }
private static void VerifyProgress(IProgressVisualizer visualizer, double mainProgress, ProgressStepViewModel current, double subProgress) { visualizer.ViewModel.MainProgress.Value.Should().BeApproximately(mainProgress, FloatingPointError, "Unexpected main progress"); if (current == null) { visualizer.ViewModel.Current.Should().BeNull("Not expecting any current step"); } else { visualizer.ViewModel.Current.Should().Be(current, "Unexpected current step"); if (double.IsNaN(subProgress)) { double.IsNaN(current.Progress.Value).Should().BeTrue("Unexpected sub progress"); } else { current.Progress.Value.Should().BeApproximately(subProgress, FloatingPointError, "Unexpected sub progress"); } } }
public static void Run( [NotNull] IServiceProvider provider, bool allowCancel, [NotNull] Action <IProgressVisualizer> work, [CanBeNull] Action completeHandler) { if (provider == null) { throw new ArgumentNullException("provider"); } if (work == null) { throw new ArgumentNullException("work"); } IProgressVisualizer progressVisualizer = null; AsyncHelper.RunAsync( asyncOp => { progressVisualizer = provider .GetRequiredService <IProgressService>() .CreateVisualizer(allowCancel); work(progressVisualizer); }, () => { progressVisualizer.Complete(); if (completeHandler != null) { completeHandler(); } }); Application.DoEvents(); }
internal ProgressObserver(IServiceProvider serviceProvider, IProgressVisualizer host, IProgressEvents progressEvents, ProgressControllerViewModel state) { // Event registration must be on the UI thread ThreadHelper.ThrowIfNotOnUIThread(); if (serviceProvider == null) { throw new ArgumentNullException(nameof(serviceProvider)); } if (host == null) { throw new ArgumentNullException(nameof(host)); } if (progressEvents == null) { throw new ArgumentNullException(nameof(progressEvents)); } Debug.Assert(progressEvents.Steps != null, "Expected to be initialized"); this.serviceProvider = serviceProvider; this.host = host; this.progressEvents = progressEvents; this.progressEvents.Started += this.ControllerStarted; this.progressEvents.Finished += this.ControllerFinished; this.progressEvents.StepExecutionChanged += this.OnStepExecutionChanged; this.progressEvents.CancellationSupportChanged += this.OnCancellationSupportChanged; this.viewModelRoot = state ?? new ProgressControllerViewModel(); this.InitializeStepViewModels(); this.host.ViewModel = this.viewModelRoot; }
internal ProgressObserver(IServiceProvider serviceProvider, IProgressVisualizer host, IProgressEvents progressEvents, ProgressControllerViewModel state) { // Event registration must be on the UI thread ThreadHelper.ThrowIfNotOnUIThread(); if (serviceProvider == null) { throw new ArgumentNullException(nameof(serviceProvider)); } if (host == null) { throw new ArgumentNullException(nameof(host)); } if (progressEvents == null) { throw new ArgumentNullException(nameof(progressEvents)); } Debug.Assert(progressEvents.Steps != null, "Expected to be initialized"); this.serviceProvider = serviceProvider; this.host = host; this.progressEvents = progressEvents; this.progressEvents.Started += this.ControllerStarted; this.progressEvents.Finished += this.ControllerFinished; this.progressEvents.StepExecutionChanged += this.OnStepExecutionChanged; this.progressEvents.CancellationSupportChanged += this.OnCancellationSupportChanged; this.viewModelRoot = state ?? new ProgressControllerViewModel(); this.InitializeStepViewModels(); this.host.ViewModel = this.viewModelRoot; }
public static ProgressObserver StartObserving(IServiceProvider serviceProvider, IProgressEvents progressEvents, IProgressVisualizer visualizer, ProgressControllerViewModel state) { if (serviceProvider == null) { throw new ArgumentNullException(nameof(serviceProvider)); } if (progressEvents == null) { throw new ArgumentNullException(nameof(progressEvents)); } if (visualizer == null) { throw new ArgumentNullException(nameof(visualizer)); } CheckSupportedProgressEvents(progressEvents); ProgressObserver observer = CreateAndConfigureInstance(serviceProvider, visualizer, progressEvents, null, state); Debug.Assert(observer != null, "Failed to create observer on the UI thread"); return observer; }
public static ProgressObserver StartObserving(IServiceProvider serviceProvider, IProgressEvents progressEvents, IProgressVisualizer visualizer) { return StartObserving(serviceProvider, progressEvents, visualizer, null); }
public static ProgressObserver StartObserving(IProgressController controller, IProgressVisualizer visualizer, ProgressControllerViewModel state) { if (controller == null) { throw new ArgumentNullException(nameof(controller)); } if (visualizer == null) { throw new ArgumentNullException(nameof(visualizer)); } CheckSupportedController(controller); ProgressObserver observer = CreateAndConfigureInstance((IServiceProvider)controller, visualizer, controller.Events, new RelayCommand((s) => controller.TryAbort()), state); Debug.Assert(observer != null, "Failed to create observer on the UI thread"); return observer; }
public static ProgressObserver StartObserving(IProgressController controller, IProgressVisualizer visualizer) { return StartObserving(controller, visualizer, null); }
public ExecutionVerifier(IProgressVisualizer visualizer, ProgressObserver testSubject) { Assert.IsNotNull(visualizer != null, "IProgressVisualizer is expected"); Assert.IsNotNull(testSubject != null, "ProgressObserver is expected"); this.visualizer = visualizer; this.testSubject = testSubject; }
private static void VerifyProgress(IProgressVisualizer visualizer, double mainProgress, ProgressStepViewModel current, double subProgress) { Assert.AreEqual(mainProgress, visualizer.ViewModel.MainProgress.Value, FloatingPointError, "Unexpected main progress"); if (current == null) { Assert.IsNull(visualizer.ViewModel.Current, "Not expecting any current step"); } else { Assert.AreSame(current, visualizer.ViewModel.Current, "Unexpected current step"); if (double.IsNaN(subProgress)) { Assert.IsTrue(double.IsNaN(current.Progress.Value), "Unexpected sub progress"); } else { Assert.AreEqual(subProgress, current.Progress.Value, FloatingPointError, "Unexpected sub progress"); } } }
public SdkInstaller(IFileUnpackService fileUnpackService, IProgressVisualizer progressVisualizer, ISettingsProvider settingsProvider) { this.fileUnpackService = fileUnpackService; this.progressVisualizer = progressVisualizer; this.settingsProvider = settingsProvider; }
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)); }
public static ProgressObserver StartObserving(IServiceProvider serviceProvider, IProgressEvents progressEvents, IProgressVisualizer visualizer) { return(StartObserving(serviceProvider, progressEvents, visualizer, null)); }
public static ProgressObserver StartObserving(IServiceProvider serviceProvider, IProgressEvents progressEvents, IProgressVisualizer visualizer, ProgressControllerViewModel state) { if (serviceProvider == null) { throw new ArgumentNullException(nameof(serviceProvider)); } if (progressEvents == null) { throw new ArgumentNullException(nameof(progressEvents)); } if (visualizer == null) { throw new ArgumentNullException(nameof(visualizer)); } CheckSupportedProgressEvents(progressEvents); ProgressObserver observer = CreateAndConfigureInstance(serviceProvider, visualizer, progressEvents, null, state); Debug.Assert(observer != null, "Failed to create observer on the UI thread"); return(observer); }
private static ProgressObserver Observe(IProgressController controller, IProgressVisualizer visualizer) { ProgressObserver observer = CreateObserver(controller, visualizer, null); observedControllersMap.Add(controller, observer); return observer; }
public static ProgressObserver StartObserving(IProgressController controller, IProgressVisualizer visualizer) { return(StartObserving(controller, visualizer, null)); }
private static ProgressObserver CreateObserver(IProgressController controller, IProgressVisualizer visualizer, ProgressControllerViewModel state) { return(ProgressObserver.StartObserving(controller, visualizer, state)); }
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 static ProgressObserver CreateObserver(IProgressController controller, IProgressVisualizer visualizer, ProgressControllerViewModel state) { return ProgressObserver.StartObserving(controller, visualizer, state); }
public static ProgressObserver StartObserving(IProgressController controller, IProgressVisualizer visualizer, ProgressControllerViewModel state) { if (controller == null) { throw new ArgumentNullException(nameof(controller)); } if (visualizer == null) { throw new ArgumentNullException(nameof(visualizer)); } CheckSupportedController(controller); ProgressObserver observer = CreateAndConfigureInstance((IServiceProvider)controller, visualizer, controller.Events, new RelayCommand((s) => controller.TryAbort()), state); Debug.Assert(observer != null, "Failed to create observer on the UI thread"); return(observer); }
void Awake() { boardSizer = GetComponent <Board>(); progressVisual = GetComponent <BoardProgressVisualizer>(); }