Sleep thread
C#
3
Posts
3
Posters
0
Views
1
Watching
-
Hi, How can i sleep a thread for ever and how to continue the thread which is sleeping for ever? I need to use in pause and play. Thankyou YPKI
-
Hi, How can i sleep a thread for ever and how to continue the thread which is sleeping for ever? I need to use in pause and play. Thankyou YPKI
-
I agree,
ManualResetEvent
is IMHO the best solution. In your case you might not need a timeout, however, because a long pause does not indicate an exceptional case (if you are making a "play/pause" sort of functionality). But remember to implement IDisposable in your class, and signal the ManualResetEvent before Disposing to make sure that your background thread ends also, otherwise you will end up waiting forever.