Example #1
0
 public CodeConversion(IAsyncServiceProvider serviceProvider,
                       JoinableTaskFactory joinableTaskFactory, Cancellation packageCancellation, VisualStudioWorkspace visualStudioWorkspace,
                       Func <Task <ConverterOptionsPage> > getOptions, OutputWindow outputWindow)
 {
     GetOptions             = getOptions;
     _serviceProvider       = serviceProvider;
     _joinableTaskFactory   = joinableTaskFactory;
     _visualStudioWorkspace = visualStudioWorkspace;
     _outputWindow          = outputWindow;
     _packageCancellation   = packageCancellation;
 }
 internal static void Initialize(Cancellation packageCancellation)
 {
     CancelAllToken = packageCancellation.CancelAll;
 }
        public OleMenuCommandWithBlockingStatus(JoinableTaskFactory joinableTaskFactory, Cancellation _packageCancellation, Func <CancellationToken, Task> callbackAsync, CommandID menuCommandId)
        {
            _joinableTaskFactory = joinableTaskFactory;
            _command             = new OleMenuCommand(Execute, menuCommandId);

            void Execute(object sender, EventArgs eventArgs)
            {
                var cancellationTokenSource = _packageCancellation.ResetCommandCancellation();

                async Task ExecuteAsync()
                {
                    await TaskScheduler.Default;

                    await callbackAsync(cancellationTokenSource.Token);
                }

                _joinableTaskFactory.RunAsync(ExecuteAsync).Task.Forget();
            }
        }