Pausing thread has been recognized as dangerous and is not available in .NET.
Here is what you need to use instead of Pause/Resume: one of the classes:
; please see:
The first class can be used instead the other two; they are only different in the way how the event handle is reset: automatically or only explicitly.
The idea is this: the event has two states, signaled or non-signaled. One can signal the event by the call to
and un-signal calling
or it will be reset automatically by a waiting thread. Now, you pause the thread by calling
EventWaitHandle.WaitOne by the thread to be paused
. If the event is non-signaled, the thread is put in the wait state: it is switched out by the OS and never scheduled back to execution until it is awaken. It will be awaken if some other thread
on the same instance
of event wait handle; it also will be awaken by a timeout (optional wait parameter) or
When a thread is awaken and the event handle uses auto-reset, it will be reset back to non-signaled state immediately on the wake-up of the thread. This transition is atomic
and cannot be reliably simulated by other methods (such as Boolean condition). This auto-reset mechanism is designed to pass one and only one waiting thread at a time and make other threads waiting on the same event handle instance in the wait state.