public Task InterruptAsync(CancellationToken ct) { try { return(_session.CancelAllAsync(ct)); } catch (OperationCanceledException) { } return(Task.CompletedTask); }
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"); } } }
public async Task InvokeAsync() { if (CanInterrupt()) { _interactiveWorkflow.Operations.ClearPendingInputs(); await _session.CancelAllAsync(); } }
protected override void Handle() { if (_enabled) { _interactiveWorkflow.Operations.ClearPendingInputs(); _session.CancelAllAsync().DoNotWait(); _enabled = false; } }
public async Task InvokeAsync() { if (_enabled) { _enabled = false; _interactiveWorkflow.Operations.ClearPendingInputs(); await _session.CancelAllAsync(); } }
public async Task <CommandResult> InvokeAsync() { if (_enabled) { _enabled = false; _interactiveWorkflow.Operations.ClearPendingInputs(); await _session.CancelAllAsync(); return(CommandResult.Executed); } return(CommandResult.NotSupported); }
public void AbortExecution() { Session.CancelAllAsync().DoNotWait(); }