You must Sign In to post a response.
  • Category: .NET

    Cancelling Thread.Sleep

    I'm using a background worker in my project & in my DoWork method i run a infinite loop with a Thread.Sleep of 15mins. Now if i call CancelAsync() method there seems to be no effect since the thread is in sleep mode. From what i researched we need to use Threading & cancellation token. Can anyone explain me how to implement this efficiently. Also based on some conditions i will need to restart the DoWork method as well..

    Karthick V
  • #761854
    Hi Karthik.

    Go through the below links which I found use full in your case.


    Sridhar Thota.
    If you learn't from defeat..
    You haven't really lost..

    Sridhar Thota.
    Editor: DNS Forum.

  • #761857
    Hi Sridhar,
    Thanks for the reply. I've tried this but it seems to be blocking the UI. I need a asynchronous solution for this. Please provide me a sample if possible..

    Karthick V

  • Sign In to post your comments