public abstract class WaitHandle : MarshalByRefObject, IDisposable
Object
MarshalByRefObject
WaitHandleThis type implements IDisposable.
mscorlib
BCL
Encapsulates operating-system specific objects that wait for exclusive access to shared resources.
[Note: This class is typically used as a base class for synchronization objects. Classes derived from WaitHandle define a signaling mechanism to indicate taking or releasing exclusive access to a shared resource, but use the inherited WaitHandle methods to block while waiting for access to shared resources.The static methods of this class are used to block a Thread until one or more synchronization objects receive a signal.
]
System.Threading Namespace
WaitHandle Constructors
WaitHandle Methods
WaitHandle.Close Method
WaitHandle.Dispose Method
WaitHandle.Finalize Method
WaitHandle.System.IDisposable.Dispose Method
WaitHandle.WaitAll Method
WaitHandle.WaitAny Method
WaitHandle.WaitOne Method
public WaitHandle();
Constructs and initializes a new instance of the WaitHandle class.
System.Threading.WaitHandle Class, System.Threading Namespace
public virtual void Close();
Releases all resources held by the current instance.
This method is the public version of the System.IDisposable.Dispose method implemented to support the IDisposable interface.[Behaviors: This method releases any unmanaged resources held by the current instance. This method can, but is not required to, suppress finalization during garbage collection by calling the System.GC.SuppressFinalize(System.Object) method. ]
[Default: As described above.]
[Overrides: Override this property to release resources allocated in subclasses. ]
[Usage: Use this method to release all resources held by an instance of
WaitHandle
. Once this method is called, references to the current instance cause undefined behavior. ]
System.Threading.WaitHandle Class, System.Threading Namespace
protected virtual void Dispose(bool explicitDisposing);
Releases the unmanaged resources used by the WaitHandle and optionally releases the managed resources.
- explicitDisposing
true
to release both managed and unmanaged resources;false
to release only unmanaged resources.
[Behaviors: This method releases all unmanaged resources held by the current instance. When the explicitDisposing parameter istrue
, this method releases all resources held by any managed objects referenced by the current instance. This method invokes theDispose()
method of each referenced object.]
[Overrides: Override this method to dispose of resources allocated by types derived from WaitHandle. When overriding
Dispose
(Boolean), be careful not to reference objects that have been previously disposed in an earlier call toDispose
orClose
.Dispose
can be called multiple times by other objects. ]
[Usage: This method is called by the public System.Threading.WaitHandle.Dispose(System.Boolean) method and the System.Object.Finalize method.
Dispose()
invokes this method with the explicitDisposing parameter set totrue
. System.Object.Finalize invokesDispose
with explicitDisposing set tofalse
.]
System.Threading.WaitHandle Class, System.Threading Namespace
~WaitHandle();
Releases the resources held by the current instance.
[Note: Application code does not call this method; it is automatically invoked during garbage collection unless finalization by the garbage collector has been disabled. For more information, see System.GC.SuppressFinalize(System.Object), and System.Object.Finalize.This method overrides System.Object.Finalize.
]
System.Threading.WaitHandle Class, System.Threading Namespace
void IDisposable.Dispose();
Implemented to support the IDisposable interface. [Note: For more information, see System.IDisposable.Dispose.]
System.Threading.WaitHandle Class, System.Threading Namespace
public static bool WaitAll(WaitHandle[] waitHandles);
Waits for all of the elements in the specified array to receive a signal.
- waitHandles
- A WaitHandle array containing the objects for which the current instance will wait. This array cannot contain multiple references to the same object (duplicates).
Returnstrue
when every element in waitHandles has received a signal. If the current thread receives a request to abort before the signals are received, this method returnsfalse
.
Exception Type Condition ArgumentNullException waitHandles is null
or one or more elements in the waitHandles array isnull
.DuplicateWaitObjectException waitHandles contains elements that are duplicates. NotSupportedException The number of objects in waitHandles is greater than the system permits.
The maximum number of objects specified in the waitHandles array is system defined.
System.Threading.WaitHandle Class, System.Threading Namespace
public static int WaitAny(WaitHandle[] waitHandles);
Waits for any of the elements in the specified array to receive a signal.
- waitHandles
- A WaitHandle array containing the objects for which the current instance will wait. This array cannot contain multiple references to the same object (duplicates).
Returns a Int32 set to the index of the element in waitHandles that received a signal.
Exception Type Condition ArgumentNullException waitHandles is null
or one or more elements in the waitHandles array isnull
.DuplicateWaitObjectException waitHandles contains elements that are duplicates. NotSupportedException The number of objects in waitHandles is greater than the system permits.
The maximum number of objects specified in the waitHandles array is system defined.
System.Threading.WaitHandle Class, System.Threading Namespace
public virtual bool WaitOne();
Blocks the current thread until the current instance receives a signal.
Returnstrue
when the current instance receives a signal.
Exception Type Condition ObjectDisposedException The current instance has already been disposed.
[Behaviors: The caller of this method blocks indefinitely until a signal is received by the current instance. ]
[Overrides: Override this method to customize the behavior of types derived from WaitHandle .]
[Usage: Use this method to block until a
WaitHandle
receives a signal from another thread, such as is generated when an asynchronous operation completes. For more information, see the IAsyncResult interface.]
System.Threading.WaitHandle Class, System.Threading Namespace