How to pause Asynchronous Method?
How can I pause Asynchronous Metho开发者_JAVA百科ds?
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 :-)
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.
精彩评论