开发者

Does AutoResetEvent.WaitOne() frees a slot in the thread pool?

I am trying to synchronize an asynchronous method. The main advantage of the async version is that it frees a slot in the thread pool. I would like to keep this advantage in my开发者_JS百科 sync version. When I use AutoResetEvent.WaitOne() it is equivalent to a Thread.Sleep() in terms of thread pool usage?


When you call WaitOne the current thread will block and wait for the event to be signaled. Just like with Thread.Sleep the thread will not be released to the thread pool. The difference is that with Thread.Sleep you need to specify a fixed time during which the current thread will be blocked, while WaitOne will block until some other thread calls Set or a timeout occurs.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜