Beispiel #1
0
 public Task InterruptAsync(CancellationToken ct)
 {
     try {
         return(_session.CancelAllAsync(ct));
     } catch (OperationCanceledException) { }
     return(Task.CompletedTask);
 }
Beispiel #2
0
        private async Task ExitBrowserAsync(IRSession session)
        {
            await TaskUtilities.SwitchToBackgroundThread();

            var cts = new CancellationTokenSource(1000);
            IRSessionInteraction inter;

            try {
                inter = await session.BeginInteractionAsync(true, cts.Token);
            } catch (OperationCanceledException) {
                // If we couldn't get a prompt to put "Q" into within a reasonable timeframe, just
                // abort the current interaction;
                await session.CancelAllAsync();

                return;
            }

            using (inter) {
                // Check if this is still the same prompt as the last Browse prompt that we've seen.
                // If it isn't, then session has moved on already, and there's nothing for us to exit.
                RBrowseEventArgs currentBrowseDebugEventArgs;
                lock (_browseLock) {
                    currentBrowseDebugEventArgs = _currentBrowseEventArgs;
                }

                if (currentBrowseDebugEventArgs != null && currentBrowseDebugEventArgs.Context.Contexts == inter.Contexts)
                {
                    await inter.RespondAsync("Q\n");
                }
            }
        }
Beispiel #3
0
 public async Task InvokeAsync()
 {
     if (CanInterrupt())
     {
         _interactiveWorkflow.Operations.ClearPendingInputs();
         await _session.CancelAllAsync();
     }
 }
Beispiel #4
0
 protected override void Handle()
 {
     if (_enabled)
     {
         _interactiveWorkflow.Operations.ClearPendingInputs();
         _session.CancelAllAsync().DoNotWait();
         _enabled = false;
     }
 }
Beispiel #5
0
 public async Task InvokeAsync()
 {
     if (_enabled)
     {
         _enabled = false;
         _interactiveWorkflow.Operations.ClearPendingInputs();
         await _session.CancelAllAsync();
     }
 }
Beispiel #6
0
        public async Task <CommandResult> InvokeAsync()
        {
            if (_enabled)
            {
                _enabled = false;
                _interactiveWorkflow.Operations.ClearPendingInputs();
                await _session.CancelAllAsync();

                return(CommandResult.Executed);
            }

            return(CommandResult.NotSupported);
        }
Beispiel #7
0
 public void AbortExecution()
 {
     Session.CancelAllAsync().DoNotWait();
 }
Beispiel #8
0
        private async Task ExitBrowserAsync(IRSession session) {
            await TaskUtilities.SwitchToBackgroundThread();

            var cts = new CancellationTokenSource(1000);
            IRSessionInteraction inter;
            try {
                inter = await session.BeginInteractionAsync(true, cts.Token);
            } catch (OperationCanceledException) {
                // If we couldn't get a prompt to put "Q" into within a reasonable timeframe, just
                // abort the current interaction;
                await session.CancelAllAsync();
                return;
            }

            using (inter) {
                // Check if this is still the same prompt as the last Browse prompt that we've seen.
                // If it isn't, then session has moved on already, and there's nothing for us to exit.
                RBrowseEventArgs currentBrowseDebugEventArgs;
                lock (_browseLock) {
                    currentBrowseDebugEventArgs = _currentBrowseEventArgs;
                }

                if (currentBrowseDebugEventArgs != null && currentBrowseDebugEventArgs.Context.Contexts == inter.Contexts) {
                    await inter.RespondAsync("Q\n");
                }
            }
        }