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

1k Views Asked by At

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 sync version. When I use AutoResetEvent.WaitOne() it is equivalent to a Thread.Sleep() in terms of thread pool usage?

1

There are 1 best solutions below

1
On BEST ANSWER

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.