public CommandResponse Handle(NestedTestTokenCancellableCmd command)
 {
     for (int i = 0; i < 5; i++)
     {
         if (command.IsCanceled)
         {
             return(command.Canceled());
         }
         Thread.Sleep(200);
     }
     return(command.Succeed());
 }
        public CommandResponse Handle(TestTokenCancellableCmd command)
        {
            Interlocked.Increment(ref _gotCmd);
            var nestedCommand = new NestedTestTokenCancellableCmd(command.CancellationToken.Value);

            if (_cancelFirst)
            {
                TokenSource.Cancel();     //global cancel
                _bus.Send(nestedCommand); // a pre canceled command will just return
            }
            else
            {
                AssertEx.CommandThrows <CommandCanceledException>(
                    () => {
                    _bus.Send(nestedCommand);
                });
            }
            return(command.IsCanceled ? command.Canceled() : command.Succeed());
        }
 public CommandResponse Handle(NestedTestTokenCancellableCmd command)
 {
     Interlocked.Increment(ref _gotNestedCmd);
     TokenSource.Cancel();
     return(command.IsCanceled ? command.Canceled() : command.Succeed());
 }