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?
I am trying to synchronize an asynchronous method. The main advantage of the async
Share
When you call
WaitOnethe current thread will block and wait for the event to be signaled. Just like withThread.Sleepthe thread will not be released to the thread pool. The difference is that withThread.Sleepyou need to specify a fixed time during which the current thread will be blocked, whileWaitOnewill block until some other thread callsSetor a timeout occurs.