Use CancellationToken to Make Responsive Thread.Sleep() Wait
Using a time delay based on a Thread.Sleep() is truly easy. However, if you need a pause inside code that is using a CancellationToken, be aware that if the CancellationTokenSource calls the Cancel() method, Thread.Sleep() will ignore the request. CancellationToken Aware Sleep() In the example below, we get the WaitHandle from the token and pass in delay time… Read More »