Event arguments for a single IProgressStep being executed by the IProgressController IProgressEvents
Inheritance: ProgressEventArgs
 public void InvokeStepExecutionChanged(StepExecutionChangedEventArgs args)
 {
     if (this.StepExecutionChanged != null)
     {
         this.StepExecutionChanged(this, args); 
     }
 }
 private void OnStepExecutionChanged(object sender, StepExecutionChangedEventArgs e)
 {
     if (!string.IsNullOrWhiteSpace(e.ProgressDetailText) && !StringComparer.CurrentCulture.Equals(previousProgressDetail, e.ProgressDetailText))
     {
         previousProgressDetail = e.ProgressDetailText;
         string format = string.IsNullOrWhiteSpace(this.MessageFormat) ? "{0}" : this.MessageFormat;
         VsShellUtils.WriteToSonarLintOutputPane(this.serviceProvider, format, e.ProgressDetailText);
     }
 }
Example #3
0
 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();
             }
         });
     }
 }
        /// <summary>
        /// Updates the <see cref="ProgressStepViewModel"/> with the current step changes.
        /// The <see cref="ProgressStepViewModel"/> represents a <see cref="ExecutionGroup"/>
        /// of one visible step and zero or more hidden steps. The progress in <see cref="ProgressStepViewModel"/>
        /// is used as the sub progress and it will be indeterminate if there's one indeterminate
        /// <see cref="IProgressStep"/> in <see cref="ExecutionGroup"/>, otherwise the sub progress
        /// will be relative to the number of steps in <see cref="ExecutionGroup"/>.
        /// </summary>
        /// <param name="e">Execution update</param>
        private void UpdateViewModelStep(StepExecutionChangedEventArgs e)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            ProgressStepViewModel vm = this.progressStepToViewModelMapping[e.Step];
            ExecutionGroup executionGroup = this.viewModelToExecutionGroupMapping[vm];

            bool isLastStep = e.Step == executionGroup.Steps.Last();
            double groupCompletionPercentange = GetCompletedStepCount(executionGroup.Steps) / (double)executionGroup.Steps.Count;
            this.CurrentExecutingGroup = executionGroup;
            executionGroup.ExecutingStep = e.Step;

            // Update the step VM
            // Progress update: Indeterminate step progress should remain as it was
            // and the determinate step progress should be updated
            switch (e.State)
            {
                case StepExecutionState.NotStarted:
                    Debug.Fail("Unexpected transition to NotStarted");
                    if (!vm.Progress.IsIndeterminate)
                    {
                        vm.Progress.SetUpperBoundLimitedValue(0);
                    }

                    break;
                case StepExecutionState.Executing:
                    if (!vm.Progress.IsIndeterminate)
                    {
                        Debug.Assert(!executionGroup.Steps.Any(s => s.Indeterminate), "Not expecting any Indeterminate steps");

                        vm.Progress.SetUpperBoundLimitedValue(groupCompletionPercentange + (e.Progress / (double)executionGroup.Steps.Count));
                    }

                    vm.ExecutionState = e.State;
                    vm.ProgressDetailText = e.ProgressDetailText;

                    break;
                default:
                    Debug.Assert(ProgressControllerHelper.IsFinalState(e.State), "Unexpected non-final state", "State: {0}", e.State);
                    if (!vm.Progress.IsIndeterminate)
                    {
                        vm.Progress.SetUpperBoundLimitedValue(groupCompletionPercentange);
                    }

                    // Succeeded state which is not the last will indicate
                    // that the group is still executing
                    if (e.State == StepExecutionState.Succeeded && !isLastStep)
                    {
                        vm.ExecutionState = StepExecutionState.Executing;
                    }
                    else
                    {
                        vm.ExecutionState = e.State;
                    }

                    executionGroup.ExecutingStep = null;
                    if (isLastStep)
                    {
                        vm.ProgressDetailText = null;
                        this.CurrentExecutingGroup = null;
                    }

                    break;
            }

            vm.ProgressDetailText = e.ProgressDetailText;
        }
        /// <summary>
        /// Updates the main progress based on the number of steps in final state
        /// an the current step being executed. Each <see cref="IProgressStep"/> which impacts
        /// progress will have one "slot" in the main progress bar.
        /// </summary>
        /// <param name="e">Execution update</param>
        private void UpdateMainProgress(StepExecutionChangedEventArgs e)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            double totalNumberOfSteps = this.ProgressImpactingSteps.Count();
            double completedSteps = GetCompletedStepCount(this.ProgressImpactingSteps);

            this.viewModelRoot.Current = this.progressStepToViewModelMapping[e.Step];

            this.viewModelRoot.MainProgress.SetUpperBoundLimitedValue(completedSteps / totalNumberOfSteps);

            // When a determinate step is executing take it's progress into account
            if (!e.IsProgressIndeterminate() && e.State == StepExecutionState.Executing)
            {
                this.viewModelRoot.MainProgress.SetUpperBoundLimitedValue(this.viewModelRoot.MainProgress.Value + e.Progress / totalNumberOfSteps);
            }
        }
        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();
            }
        }
        private void OnStepExecutionChanged(object sender, StepExecutionChangedEventArgs e)
        {
            AssertEventHandlerArgsNotNull(sender, e);

            List<StepExecutionChangedEventArgs> list;
            if (!this.executionChanges.TryGetValue(e.Step, out list))
            {
                this.executionChanges[e.Step] = list = new List<StepExecutionChangedEventArgs>();
            }

            list.Add(e);
            // Satisfy the sequential controller verification code
            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();
                 }
             });
     }
 }