diff --git a/src/Bank2Adapter/Handlers/QuoteRequestedHandler.cs b/src/Bank2Adapter/Handlers/QuoteRequestedHandler.cs index 0e27c54..05c0936 100644 --- a/src/Bank2Adapter/Handlers/QuoteRequestedHandler.cs +++ b/src/Bank2Adapter/Handlers/QuoteRequestedHandler.cs @@ -14,11 +14,20 @@ public async Task Handle(QuoteRequested message, IMessageHandlerContext context) while (DateTime.Now.Ticks % 300 == 0) { + if (context.CancellationToken.IsCancellationRequested) + { + return; + } throw new Exception("Random error"); } while (DateTime.Now.Ticks % 5 == 0) { + if (context.CancellationToken.IsCancellationRequested) + { + return; + } + var randomDelayMilliseconds = Random.Next(500, 3000); Thread.Sleep(randomDelayMilliseconds); }