public override async Task <bool> NextResultAsync(CancellationToken cancellationToken)
 {
     VerifyNotDisposed();
     Command !.CancellableCommand.ResetCommandTimeout();
     using var registration = Command.CancellableCommand.RegisterCancel(cancellationToken);
     return(await NextResultAsync(Command?.Connection?.AsyncIOBehavior ?? IOBehavior.Asynchronous, cancellationToken).ConfigureAwait(false));
 }
 public override async Task <bool> ReadAsync(CancellationToken cancellationToken)
 {
     VerifyNotDisposed();
     Command !.CancellableCommand.ResetCommandTimeout();
     using var registration = Command.CancellableCommand.RegisterCancel(cancellationToken);
     return(await m_resultSet !.ReadAsync(cancellationToken).ConfigureAwait(false));
 }
Example #3
0
        public void user_code_can_react_to_cancel_command_using_KernelInvocationContext_cancellation_token()
        {
            using var kernel = CreateKernel();
            var commandInProgress = new CancellableCommand();
            var cancelSent        = commandInProgress.Invoked.ContinueWith(async task =>
            {
                // once the cancellable command is running, send a Cancel
                await kernel.SendAsync(new Cancel());
            });

            var _ = kernel.SendAsync(commandInProgress);

            Task.WhenAll(cancelSent, commandInProgress.Cancelled)
            .Wait(TimeSpan.FromSeconds(5));
        }
Example #4
0
        public async Task cancel_issues_CommandSucceeded()
        {
            var kernel = CreateKernel();

            var cancelCommand = new Cancel();

            var commandToCancel = new CancellableCommand();

            var _ = kernel.SendAsync(commandToCancel);
            await kernel.SendAsync(cancelCommand);

            KernelEvents
            .Should()
            .ContainSingle <CommandSucceeded>(c => c.Command == cancelCommand);
        }
Example #5
0
        public async Task new_commands_issued_after_cancel_are_executed()
        {
            var kernel = CreateKernel();

            var cancelCommand = new Cancel();

            var commandToCancel = new CancellableCommand();

            var commandToRun = new SubmitCode("1");

            var _ = kernel.SendAsync(commandToCancel);
            await kernel.SendAsync(cancelCommand);

            await kernel.SendAsync(commandToRun);

            KernelEvents
            .Should()
            .ContainSingle <CommandSucceeded>(c => c.Command == commandToRun);
        }
Example #6
0
 public override Task <bool> ReadAsync(CancellationToken cancellationToken)
 {
     VerifyNotDisposed();
     Command !.CancellableCommand.ResetCommandTimeout();
     return(m_resultSet !.ReadAsync(cancellationToken));
 }
Example #7
0
 public override bool Read()
 {
     VerifyNotDisposed();
     Command !.CancellableCommand.ResetCommandTimeout();
     return(m_resultSet !.Read());
 }