Beispiel #1
0
        /// <summary>
        /// Completes work registered in <see cref="IntelliSenseCheckBox_Checked(object, RoutedEventArgs)"/>.
        /// </summary>
        private void IntelliSenseCheckBox_Unchecked(object sender, RoutedEventArgs e)
        {
            // Complete the task
            this.taskCompletionSource.SetResult(true);
            this.taskCompletionSource = null;

            // Close the access to the stage
            this.intelliSenseStageAccess.Dispose();
            this.intelliSenseStageAccess = null;
        }
Beispiel #2
0
        /// <summary>
        /// Registers Test work with the Operation Progress service.
        /// </summary>
        private void IntelliSenseCheckBox_Checked(object sender, RoutedEventArgs e)
        {
            if (this.intelliSenseStageAccess != null)
            {
                return;
            }

            // Get access to the stage
            this.intelliSenseStageAccess = vsOperationProgressService.AccessStage(StageId, "test", 1);

            // Create a task that tracks the work and register it with the operation progress
            this.taskCompletionSource = new TaskCompletionSource <bool>();

            // Create a JoinableTask that represents the work.
            // We use JoinableTask to allow JoinableTaskFactory to track the entire chain between operation progress producers and awaiters in order to avoid deadlocks.
            JoinableTask joinableTask = this.joinableTaskFactory.RunAsync(() => taskCompletionSource.Task);

            intelliSenseStageAccess.RegisterTask(new OperationProgressTask(joinableTask, "Test", () => Task.FromResult("Test")));
        }