Reputation: 7653
How can I pause Asynchronous Methods?
Upvotes: 2
Views: 667
Reputation: 116401
You have several options: As @Darin points out, you can use Thread.Sleep, which is useful if you want to wait for a specific duration and not occupy the core in question while doing so. If you want to wait for a very short time Thread.SpinWait may be a better option, as you can avoid the context switch associated with Sleep. If you want to wait for a specific event, you can use an EventWaitHandle.
Upvotes: 1
Reputation: 1038850
Thread.Sleep in the worker method. Of course this would be a waste of thread resources because while it is paused it is not doing any useful work and threads are meant to do useful work :-)
Upvotes: 1