views:

257

answers:

1

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  A: 

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.

Darin Dimitrov
It does not? I was sure it did.. =(
Jader Dias