Description
Used to synchronize threads' activities
Class Hierarchy
- WaitHandle
- Mutex
- Semaphore
- EventWaitHandle
- EventWaitHandle
- AutoResetEvent
- ManualResetEvent
- EventWaitHandle
Mutex: provides exclusive access to a resource. It uses more system resources than Monitor class, but can be marshaled across application domain boundaries, can be used with multiple waits, and can be used to synchronize threads in different processes
Semaphores: represent a named (system wide) or local semaphore, can be used to control access to a pool of resources
AutoResetEvent: provide exclusive access to a resource. When set, the event releases the waiting thread and immediately resets, blocking subsequent threads.
ManualResetEvent is useful when one thread must complete an activity before other threads can proceed.
Important Methods
- WaitOne
- WaitAny
- WaitAll
- SignalAndWait
SignalAndWait: A thread can signal an EventWaitHandle and then block on it, as an atomic operation, by calling this static method
References
- MSDN page on WaitHandle


0 comments:
Post a Comment