mscorlib(4.0.0.0) API with additions
System.Threading.WaitHandle Class Reference

Encapsulates operating system–specific objects that wait for exclusive access to shared resources. More...

Inheritance diagram for System.Threading.WaitHandle:
[legend]
Collaboration diagram for System.Threading.WaitHandle:
[legend]

Public Member Functions

virtual bool WaitOne (int millisecondsTimeout, bool exitContext)
 Blocks the current thread until the current T:System.Threading.WaitHandle receives a signal, using a 32-bit signed integer to specify the time interval and specifying whether to exit the synchronization domain before the wait. More...
 
virtual bool WaitOne (TimeSpan timeout, bool exitContext)
 Blocks the current thread until the current instance receives a signal, using a T:System.TimeSpan to specify the time interval and specifying whether to exit the synchronization domain before the wait. More...
 
virtual bool WaitOne ()
 Blocks the current thread until the current T:System.Threading.WaitHandle receives a signal. More...
 
virtual bool WaitOne (int millisecondsTimeout)
 Blocks the current thread until the current T:System.Threading.WaitHandle receives a signal, using a 32-bit signed integer to specify the time interval in milliseconds. More...
 
virtual bool WaitOne (TimeSpan timeout)
 Blocks the current thread until the current instance receives a signal, using a T:System.TimeSpan to specify the time interval. More...
 
virtual void Close ()
 Releases all resources held by the current T:System.Threading.WaitHandle. More...
 
void Dispose ()
 Releases all resources used by the current instance of the T:System.Threading.WaitHandle class. More...
 
- Public Member Functions inherited from System.MarshalByRefObject
object GetLifetimeService ()
 Retrieves the current lifetime service object that controls the lifetime policy for this instance. More...
 
virtual object InitializeLifetimeService ()
 Obtains a lifetime service object to control the lifetime policy for this instance. More...
 
virtual ObjRef CreateObjRef (Type requestedType)
 Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. More...
 

Static Public Member Functions

static bool WaitAll (WaitHandle[] waitHandles, int millisecondsTimeout, bool exitContext)
 Waits for all the elements in the specified array to receive a signal, using an T:System.Int32 value to specify the time interval and specifying whether to exit the synchronization domain before the wait. More...
 
static bool WaitAll (WaitHandle[] waitHandles, TimeSpan timeout, bool exitContext)
 Waits for all the elements in the specified array to receive a signal, using a T:System.TimeSpan value to specify the time interval, and specifying whether to exit the synchronization domain before the wait. More...
 
static bool WaitAll (WaitHandle[] waitHandles)
 Waits for all the elements in the specified array to receive a signal. More...
 
static bool WaitAll (WaitHandle[] waitHandles, int millisecondsTimeout)
 Waits for all the elements in the specified array to receive a signal, using an T:System.Int32 value to specify the time interval. More...
 
static bool WaitAll (WaitHandle[] waitHandles, TimeSpan timeout)
 Waits for all the elements in the specified array to receive a signal, using a T:System.TimeSpan value to specify the time interval. More...
 
static int WaitAny (WaitHandle[] waitHandles, int millisecondsTimeout, bool exitContext)
 Waits for any of the elements in the specified array to receive a signal, using a 32-bit signed integer to specify the time interval, and specifying whether to exit the synchronization domain before the wait. More...
 
static int WaitAny (WaitHandle[] waitHandles, TimeSpan timeout, bool exitContext)
 Waits for any of the elements in the specified array to receive a signal, using a T:System.TimeSpan to specify the time interval and specifying whether to exit the synchronization domain before the wait. More...
 
static int WaitAny (WaitHandle[] waitHandles, TimeSpan timeout)
 Waits for any of the elements in the specified array to receive a signal, using a T:System.TimeSpan to specify the time interval. More...
 
static int WaitAny (WaitHandle[] waitHandles)
 Waits for any of the elements in the specified array to receive a signal. More...
 
static int WaitAny (WaitHandle[] waitHandles, int millisecondsTimeout)
 Waits for any of the elements in the specified array to receive a signal, using a 32-bit signed integer to specify the time interval. More...
 
static bool SignalAndWait (WaitHandle toSignal, WaitHandle toWaitOn)
 Signals one T:System.Threading.WaitHandle and waits on another. More...
 
static bool SignalAndWait (WaitHandle toSignal, WaitHandle toWaitOn, TimeSpan timeout, bool exitContext)
 Signals one T:System.Threading.WaitHandle and waits on another, specifying the time-out interval as a T:System.TimeSpan and specifying whether to exit the synchronization domain for the context before entering the wait. More...
 
static bool SignalAndWait (WaitHandle toSignal, WaitHandle toWaitOn, int millisecondsTimeout, bool exitContext)
 Signals one T:System.Threading.WaitHandle and waits on another, specifying a time-out interval as a 32-bit signed integer and specifying whether to exit the synchronization domain for the context before entering the wait. More...
 

Public Attributes

const int WaitTimeout = 258
 Indicates that a M:System.Threading.WaitHandle.WaitAny(System.Threading.WaitHandle[],System.Int32,System.Boolean) operation timed out before any of the wait handles were signaled. This field is constant. More...
 

Protected Member Functions

 WaitHandle ()
 Initializes a new instance of the T:System.Threading.WaitHandle class. More...
 
virtual void Dispose (bool explicitDisposing)
 When overridden in a derived class, releases the unmanaged resources used by the T:System.Threading.WaitHandle, and optionally releases the managed resources. More...
 
- Protected Member Functions inherited from System.MarshalByRefObject
MarshalByRefObject MemberwiseClone (bool cloneIdentity)
 Creates a shallow copy of the current T:System.MarshalByRefObject object. More...
 

Static Protected Attributes

static readonly IntPtr InvalidHandle = GetInvalidHandle()
 Represents an invalid native operating system handle. This field is read-only. More...
 

Properties

virtual IntPtr Handle [get, set]
 Gets or sets the native operating system handle. More...
 
SafeWaitHandle SafeWaitHandle [get, set]
 Gets or sets the native operating system handle. More...
 

Detailed Description

Encapsulates operating system–specific objects that wait for exclusive access to shared resources.

Definition at line 15 of file WaitHandle.cs.

Constructor & Destructor Documentation

◆ WaitHandle()

System.Threading.WaitHandle.WaitHandle ( )
protected

Initializes a new instance of the T:System.Threading.WaitHandle class.

Definition at line 131 of file WaitHandle.cs.

Member Function Documentation

◆ Close()

virtual void System.Threading.WaitHandle.Close ( )
virtual

Releases all resources held by the current T:System.Threading.WaitHandle.

Definition at line 714 of file WaitHandle.cs.

◆ Dispose() [1/2]

virtual void System.Threading.WaitHandle.Dispose ( bool  explicitDisposing)
protectedvirtual

When overridden in a derived class, releases the unmanaged resources used by the T:System.Threading.WaitHandle, and optionally releases the managed resources.

Parameters
explicitDisposingtrue to release both managed and unmanaged resources; false to release only unmanaged resources.

Definition at line 725 of file WaitHandle.cs.

◆ Dispose() [2/2]

void System.Threading.WaitHandle.Dispose ( )

Releases all resources used by the current instance of the T:System.Threading.WaitHandle class.

Implements System.IDisposable.

Definition at line 735 of file WaitHandle.cs.

◆ SignalAndWait() [1/3]

static bool System.Threading.WaitHandle.SignalAndWait ( WaitHandle  toSignal,
WaitHandle  toWaitOn 
)
static

Signals one T:System.Threading.WaitHandle and waits on another.

Parameters
toSignalThe T:System.Threading.WaitHandle to signal.
toWaitOnThe T:System.Threading.WaitHandle to wait on.
Returns
true if both the signal and the wait complete successfully; if the wait does not complete, the method does not return.
Exceptions
T:System.ArgumentNullExceptiontoSignal is null.-or- toWaitOn is null.
T:System.NotSupportedExceptionThe method was called on a thread that has T:System.STAThreadAttribute.
T:System.PlatformNotSupportedExceptionThis method is not supported on Windows 98 or Windows Millennium Edition.
T:System.InvalidOperationExceptiontoSignal is a semaphore, and it already has a full count.
T:System.Threading.AbandonedMutexExceptionThe wait completed because a thread exited without releasing a mutex. This exception is not thrown on Windows 98 or Windows Millennium Edition.

Definition at line 613 of file WaitHandle.cs.

◆ SignalAndWait() [2/3]

static bool System.Threading.WaitHandle.SignalAndWait ( WaitHandle  toSignal,
WaitHandle  toWaitOn,
TimeSpan  timeout,
bool  exitContext 
)
static

Signals one T:System.Threading.WaitHandle and waits on another, specifying the time-out interval as a T:System.TimeSpan and specifying whether to exit the synchronization domain for the context before entering the wait.

Parameters
toSignalThe T:System.Threading.WaitHandle to signal.
toWaitOnThe T:System.Threading.WaitHandle to wait on.
timeoutA T:System.TimeSpan that represents the interval to wait. If the value is -1, the wait is infinite.
exitContexttrue to exit the synchronization domain for the context before the wait (if in a synchronized context), and reacquire it afterward; otherwise, false.
Returns
true if both the signal and the wait completed successfully, or false if the signal completed but the wait timed out.
Exceptions
T:System.ArgumentNullExceptiontoSignal is null.-or- toWaitOn is null.
T:System.NotSupportedExceptionThe method was called on a thread that has T:System.STAThreadAttribute.
T:System.PlatformNotSupportedExceptionThis method is not supported on Windows 98 or Windows Millennium Edition.
T:System.InvalidOperationExceptiontoSignal is a semaphore, and it already has a full count.
T:System.ArgumentOutOfRangeExceptiontimeout evaluates to a negative number of milliseconds other than -1. -or-

timeout is greater than F:System.Int32.MaxValue.

Exceptions
T:System.Threading.AbandonedMutexExceptionThe wait completed because a thread exited without releasing a mutex. This exception is not thrown on Windows 98 or Windows Millennium Edition.

Definition at line 638 of file WaitHandle.cs.

◆ SignalAndWait() [3/3]

static bool System.Threading.WaitHandle.SignalAndWait ( WaitHandle  toSignal,
WaitHandle  toWaitOn,
int  millisecondsTimeout,
bool  exitContext 
)
static

Signals one T:System.Threading.WaitHandle and waits on another, specifying a time-out interval as a 32-bit signed integer and specifying whether to exit the synchronization domain for the context before entering the wait.

Parameters
toSignalThe T:System.Threading.WaitHandle to signal.
toWaitOnThe T:System.Threading.WaitHandle to wait on.
millisecondsTimeoutAn integer that represents the interval to wait. If the value is F:System.Threading.Timeout.Infinite, that is, -1, the wait is infinite.
exitContexttrue to exit the synchronization domain for the context before the wait (if in a synchronized context), and reacquire it afterward; otherwise, false.
Returns
true if both the signal and the wait completed successfully, or false if the signal completed but the wait timed out.
Exceptions
T:System.ArgumentNullExceptiontoSignal is null.-or- toWaitOn is null.
T:System.NotSupportedExceptionThe method is called on a thread that has T:System.STAThreadAttribute.
T:System.PlatformNotSupportedExceptionThis method is not supported on Windows 98 or Windows Millennium Edition.
T:System.InvalidOperationExceptiontoSignal is a semaphore, and it already has a full count.
T:System.ArgumentOutOfRangeExceptionmillisecondsTimeout is a negative number other than -1, which represents an infinite time-out.
T:System.Threading.AbandonedMutexExceptionThe wait completed because a thread exited without releasing a mutex. This exception is not thrown on Windows 98 or Windows Millennium Edition.
T:System.InvalidOperationExceptionThe T:System.Threading.WaitHandle cannot be signaled because it would exceed its maximum count.

Definition at line 668 of file WaitHandle.cs.

◆ WaitAll() [1/5]

static bool System.Threading.WaitHandle.WaitAll ( WaitHandle []  waitHandles,
int  millisecondsTimeout,
bool  exitContext 
)
static

Waits for all the elements in the specified array to receive a signal, using an T:System.Int32 value to specify the time interval and specifying whether to exit the synchronization domain before the wait.

Parameters
waitHandlesA WaitHandle array containing the objects for which the current instance will wait. This array cannot contain multiple references to the same object (duplicates).
millisecondsTimeoutThe number of milliseconds to wait, or F:System.Threading.Timeout.Infinite (-1) to wait indefinitely.
exitContexttrue to exit the synchronization domain for the context before the wait (if in a synchronized context), and reacquire it afterward; otherwise, false.
Returns
true when every element in waitHandles has received a signal; otherwise, false.
Exceptions
T:System.ArgumentNullExceptionThe waitHandles parameter is null.-or- One or more of the objects in the waitHandles array is null. -or- waitHandles is an array with no elements and the .NET Framework version is 2.0 or later.
T:System.DuplicateWaitObjectExceptionThe waitHandles array contains elements that are duplicates.
T:System.NotSupportedExceptionThe number of objects in waitHandles is greater than the system permits.-or- The T:System.STAThreadAttribute attribute is applied to the thread procedure for the current thread, and waitHandles contains more than one element.
T:System.ApplicationExceptionwaitHandles is an array with no elements and the .NET Framework version is 1.0 or 1.1.
T:System.ArgumentOutOfRangeExceptionmillisecondsTimeout is a negative number other than -1, which represents an infinite time-out.
T:System.Threading.AbandonedMutexExceptionThe wait completed because a thread exited without releasing a mutex. This exception is not thrown on Windows 98 or Windows Millennium Edition.
T:System.InvalidOperationExceptionThe waitHandles array contains a transparent proxy for a T:System.Threading.WaitHandle in another application domain.

Definition at line 305 of file WaitHandle.cs.

◆ WaitAll() [2/5]

static bool System.Threading.WaitHandle.WaitAll ( WaitHandle []  waitHandles,
TimeSpan  timeout,
bool  exitContext 
)
static

Waits for all the elements in the specified array to receive a signal, using a T:System.TimeSpan value to specify the time interval, and specifying whether to exit the synchronization domain before the wait.

Parameters
waitHandlesA WaitHandle array containing the objects for which the current instance will wait. This array cannot contain multiple references to the same object.
timeoutA T:System.TimeSpan that represents the number of milliseconds to wait, or a T:System.TimeSpan that represents -1 milliseconds, to wait indefinitely.
exitContexttrue to exit the synchronization domain for the context before the wait (if in a synchronized context), and reacquire it afterward; otherwise, false.
Returns
true when every element in waitHandles has received a signal; otherwise false.
Exceptions
T:System.ArgumentNullExceptionThe waitHandles parameter is null. -or- One or more of the objects in the waitHandles array is null. -or- waitHandles is an array with no elements and the .NET Framework version is 2.0 or later.
T:System.DuplicateWaitObjectExceptionThe waitHandles array contains elements that are duplicates.
T:System.NotSupportedExceptionThe number of objects in waitHandles is greater than the system permits.-or- The T:System.STAThreadAttribute attribute is applied to the thread procedure for the current thread, and waitHandles contains more than one element.
T:System.ApplicationExceptionwaitHandles is an array with no elements and the .NET Framework version is 1.0 or 1.1.
T:System.ArgumentOutOfRangeExceptiontimeout is a negative number other than -1 milliseconds, which represents an infinite time-out. -or-

timeout is greater than F:System.Int32.MaxValue.

Exceptions
T:System.Threading.AbandonedMutexExceptionThe wait terminated because a thread exited without releasing a mutex. This exception is not thrown on Windows 98 or Windows Millennium Edition.
T:System.InvalidOperationExceptionThe waitHandles array contains a transparent proxy for a T:System.Threading.WaitHandle in another application domain.

Definition at line 369 of file WaitHandle.cs.

◆ WaitAll() [3/5]

static bool System.Threading.WaitHandle.WaitAll ( WaitHandle []  waitHandles)
static

Waits for all the elements in the specified array to receive a signal.

Parameters
waitHandlesA WaitHandle array containing the objects for which the current instance will wait. This array cannot contain multiple references to the same object.
Returns
true when every element in waitHandles has received a signal; otherwise the method never returns.
Exceptions
T:System.ArgumentNullExceptionThe waitHandles parameter is null. -or- One or more of the objects in the waitHandles array are null. -or- waitHandles is an array with no elements and the .NET Framework version is 2.0 or later.
T:System.DuplicateWaitObjectExceptionIn the .NET for Windows Store apps or the Portable Class Library, catch the base class exception, T:System.ArgumentException, instead.The waitHandles array contains elements that are duplicates.
T:System.NotSupportedExceptionThe number of objects in waitHandles is greater than the system permits.-or- The T:System.STAThreadAttribute attribute is applied to the thread procedure for the current thread, and waitHandles contains more than one element.
T:System.ApplicationExceptionwaitHandles is an array with no elements and the .NET Framework version is 1.0 or 1.1.
T:System.Threading.AbandonedMutexExceptionThe wait terminated because a thread exited without releasing a mutex. This exception is not thrown on Windows 98 or Windows Millennium Edition.
T:System.InvalidOperationExceptionThe waitHandles array contains a transparent proxy for a T:System.Threading.WaitHandle in another application domain.

Definition at line 393 of file WaitHandle.cs.

◆ WaitAll() [4/5]

static bool System.Threading.WaitHandle.WaitAll ( WaitHandle []  waitHandles,
int  millisecondsTimeout 
)
static

Waits for all the elements in the specified array to receive a signal, using an T:System.Int32 value to specify the time interval.

Parameters
waitHandlesA WaitHandle array containing the objects for which the current instance will wait. This array cannot contain multiple references to the same object (duplicates).
millisecondsTimeoutThe number of milliseconds to wait, or F:System.Threading.Timeout.Infinite (-1) to wait indefinitely.
Returns
true when every element in waitHandles has received a signal; otherwise, false.
Exceptions
T:System.ArgumentNullExceptionThe waitHandles parameter is null.-or- One or more of the objects in the waitHandles array is null. -or- waitHandles is an array with no elements.
T:System.DuplicateWaitObjectExceptionIn the .NET for Windows Store apps or the Portable Class Library, catch the base class exception, T:System.ArgumentException, instead.The waitHandles array contains elements that are duplicates.
T:System.NotSupportedExceptionThe number of objects in waitHandles is greater than the system permits.-or- The T:System.STAThreadAttribute attribute is applied to the thread procedure for the current thread, and waitHandles contains more than one element.
T:System.ArgumentOutOfRangeExceptionmillisecondsTimeout is a negative number other than -1, which represents an infinite time-out.
T:System.Threading.AbandonedMutexExceptionThe wait completed because a thread exited without releasing a mutex. This exception is not thrown on Windows 98 or Windows Millennium Edition.
T:System.InvalidOperationExceptionThe waitHandles array contains a transparent proxy for a T:System.Threading.WaitHandle in another application domain.

Definition at line 413 of file WaitHandle.cs.

◆ WaitAll() [5/5]

static bool System.Threading.WaitHandle.WaitAll ( WaitHandle []  waitHandles,
TimeSpan  timeout 
)
static

Waits for all the elements in the specified array to receive a signal, using a T:System.TimeSpan value to specify the time interval.

Parameters
waitHandlesA WaitHandle array containing the objects for which the current instance will wait. This array cannot contain multiple references to the same object.
timeoutA T:System.TimeSpan that represents the number of milliseconds to wait, or a T:System.TimeSpan that represents -1 milliseconds, to wait indefinitely.
Returns
true when every element in waitHandles has received a signal; otherwise, false.
Exceptions
T:System.ArgumentNullExceptionThe waitHandles parameter is null. -or- One or more of the objects in the waitHandles array is null. -or- waitHandles is an array with no elements.
T:System.DuplicateWaitObjectExceptionIn the .NET for Windows Store apps or the Portable Class Library, catch the base class exception, T:System.ArgumentException, instead.The waitHandles array contains elements that are duplicates.
T:System.NotSupportedExceptionThe number of objects in waitHandles is greater than the system permits.-or- The T:System.STAThreadAttribute attribute is applied to the thread procedure for the current thread, and waitHandles contains more than one element.
T:System.ArgumentOutOfRangeExceptiontimeout is a negative number other than -1 milliseconds, which represents an infinite time-out. -or- timeout is greater than F:System.Int32.MaxValue.
T:System.Threading.AbandonedMutexExceptionThe wait terminated because a thread exited without releasing a mutex. This exception is not thrown on Windows 98 or Windows Millennium Edition.
T:System.InvalidOperationExceptionThe waitHandles array contains a transparent proxy for a T:System.Threading.WaitHandle in another application domain.

Definition at line 434 of file WaitHandle.cs.

◆ WaitAny() [1/5]

static int System.Threading.WaitHandle.WaitAny ( WaitHandle []  waitHandles,
int  millisecondsTimeout,
bool  exitContext 
)
static

Waits for any of the elements in the specified array to receive a signal, using a 32-bit signed integer to specify the time interval, and specifying whether to exit the synchronization domain before the wait.

Parameters
waitHandlesA WaitHandle array containing the objects for which the current instance will wait.
millisecondsTimeoutThe number of milliseconds to wait, or F:System.Threading.Timeout.Infinite (-1) to wait indefinitely.
exitContexttrue to exit the synchronization domain for the context before the wait (if in a synchronized context), and reacquire it afterward; otherwise, false.
Returns
The array index of the object that satisfied the wait, or F:System.Threading.WaitHandle.WaitTimeout if no object satisfied the wait and a time interval equivalent to millisecondsTimeout has passed.
Exceptions
T:System.ArgumentNullExceptionThe waitHandles parameter is null.-or-One or more of the objects in the waitHandles array is null.
T:System.NotSupportedExceptionThe number of objects in waitHandles is greater than the system permits.
T:System.ApplicationExceptionwaitHandles is an array with no elements, and the .NET Framework version is 1.0 or 1.1.
T:System.ArgumentOutOfRangeExceptionmillisecondsTimeout is a negative number other than -1, which represents an infinite time-out.
T:System.Threading.AbandonedMutexExceptionThe wait completed because a thread exited without releasing a mutex. This exception is not thrown on Windows 98 or Windows Millennium Edition.
T:System.ArgumentExceptionwaitHandles is an array with no elements, and the .NET Framework version is 2.0 or later.
T:System.InvalidOperationExceptionThe waitHandles array contains a transparent proxy for a T:System.Threading.WaitHandle in another application domain.

Definition at line 457 of file WaitHandle.cs.

◆ WaitAny() [2/5]

static int System.Threading.WaitHandle.WaitAny ( WaitHandle []  waitHandles,
TimeSpan  timeout,
bool  exitContext 
)
static

Waits for any of the elements in the specified array to receive a signal, using a T:System.TimeSpan to specify the time interval and specifying whether to exit the synchronization domain before the wait.

Parameters
waitHandlesA WaitHandle array containing the objects for which the current instance will wait.
timeoutA T:System.TimeSpan that represents the number of milliseconds to wait, or a T:System.TimeSpan that represents -1 milliseconds to wait indefinitely.
exitContexttrue to exit the synchronization domain for the context before the wait (if in a synchronized context), and reacquire it afterward; otherwise, false.
Returns
The array index of the object that satisfied the wait, or F:System.Threading.WaitHandle.WaitTimeout if no object satisfied the wait and a time interval equivalent to timeout has passed.
Exceptions
T:System.ArgumentNullExceptionThe waitHandles parameter is null.-or-One or more of the objects in the waitHandles array is null.
T:System.NotSupportedExceptionThe number of objects in waitHandles is greater than the system permits.
T:System.ApplicationExceptionwaitHandles is an array with no elements, and the .NET Framework version is 1.0 or 1.1.
T:System.ArgumentOutOfRangeExceptiontimeout is a negative number other than -1 milliseconds, which represents an infinite time-out. -or-

timeout is greater than F:System.Int32.MaxValue.

Exceptions
T:System.Threading.AbandonedMutexExceptionThe wait completed because a thread exited without releasing a mutex. This exception is not thrown on Windows 98 or Windows Millennium Edition.
T:System.ArgumentExceptionwaitHandles is an array with no elements, and the .NET Framework version is 2.0 or later.
T:System.InvalidOperationExceptionThe waitHandles array contains a transparent proxy for a T:System.Threading.WaitHandle in another application domain.

Definition at line 529 of file WaitHandle.cs.

◆ WaitAny() [3/5]

static int System.Threading.WaitHandle.WaitAny ( WaitHandle []  waitHandles,
TimeSpan  timeout 
)
static

Waits for any of the elements in the specified array to receive a signal, using a T:System.TimeSpan to specify the time interval.

Parameters
waitHandlesA WaitHandle array containing the objects for which the current instance will wait.
timeoutA T:System.TimeSpan that represents the number of milliseconds to wait, or a T:System.TimeSpan that represents -1 milliseconds to wait indefinitely.
Returns
The array index of the object that satisfied the wait, or F:System.Threading.WaitHandle.WaitTimeout if no object satisfied the wait and a time interval equivalent to timeout has passed.
Exceptions
T:System.ArgumentNullExceptionThe waitHandles parameter is null.-or-One or more of the objects in the waitHandles array is null.
T:System.NotSupportedExceptionThe number of objects in waitHandles is greater than the system permits.
T:System.ArgumentOutOfRangeExceptiontimeout is a negative number other than -1 milliseconds, which represents an infinite time-out. -or- timeout is greater than F:System.Int32.MaxValue.
T:System.Threading.AbandonedMutexExceptionThe wait completed because a thread exited without releasing a mutex. This exception is not thrown on Windows 98 or Windows Millennium Edition.
T:System.ArgumentExceptionwaitHandles is an array with no elements.
T:System.InvalidOperationExceptionThe waitHandles array contains a transparent proxy for a T:System.Threading.WaitHandle in another application domain.

Definition at line 554 of file WaitHandle.cs.

◆ WaitAny() [4/5]

static int System.Threading.WaitHandle.WaitAny ( WaitHandle []  waitHandles)
static

Waits for any of the elements in the specified array to receive a signal.

Parameters
waitHandlesA WaitHandle array containing the objects for which the current instance will wait.
Returns
The array index of the object that satisfied the wait.
Exceptions
T:System.ArgumentNullExceptionThe waitHandles parameter is null.-or-One or more of the objects in the waitHandles array is null.
T:System.NotSupportedExceptionThe number of objects in waitHandles is greater than the system permits.
T:System.ApplicationExceptionwaitHandles is an array with no elements, and the .NET Framework version is 1.0 or 1.1.
T:System.Threading.AbandonedMutexExceptionThe wait completed because a thread exited without releasing a mutex. This exception is not thrown on Windows 98 or Windows Millennium Edition.
T:System.ArgumentExceptionwaitHandles is an array with no elements, and the .NET Framework version is 2.0 or later.
T:System.InvalidOperationExceptionThe waitHandles array contains a transparent proxy for a T:System.Threading.WaitHandle in another application domain.

Definition at line 572 of file WaitHandle.cs.

◆ WaitAny() [5/5]

static int System.Threading.WaitHandle.WaitAny ( WaitHandle []  waitHandles,
int  millisecondsTimeout 
)
static

Waits for any of the elements in the specified array to receive a signal, using a 32-bit signed integer to specify the time interval.

Parameters
waitHandlesA WaitHandle array containing the objects for which the current instance will wait.
millisecondsTimeoutThe number of milliseconds to wait, or F:System.Threading.Timeout.Infinite (-1) to wait indefinitely.
Returns
The array index of the object that satisfied the wait, or F:System.Threading.WaitHandle.WaitTimeout if no object satisfied the wait and a time interval equivalent to millisecondsTimeout has passed.
Exceptions
T:System.ArgumentNullExceptionThe waitHandles parameter is null.-or-One or more of the objects in the waitHandles array is null.
T:System.NotSupportedExceptionThe number of objects in waitHandles is greater than the system permits.
T:System.ArgumentOutOfRangeExceptionmillisecondsTimeout is a negative number other than -1, which represents an infinite time-out.
T:System.Threading.AbandonedMutexExceptionThe wait completed because a thread exited without releasing a mutex. This exception is not thrown on Windows 98 or Windows Millennium Edition.
T:System.ArgumentExceptionwaitHandles is an array with no elements.
T:System.InvalidOperationExceptionThe waitHandles array contains a transparent proxy for a T:System.Threading.WaitHandle in another application domain.

Definition at line 591 of file WaitHandle.cs.

◆ WaitOne() [1/5]

virtual bool System.Threading.WaitHandle.WaitOne ( int  millisecondsTimeout,
bool  exitContext 
)
virtual

Blocks the current thread until the current T:System.Threading.WaitHandle receives a signal, using a 32-bit signed integer to specify the time interval and specifying whether to exit the synchronization domain before the wait.

Parameters
millisecondsTimeoutThe number of milliseconds to wait, or F:System.Threading.Timeout.Infinite (-1) to wait indefinitely.
exitContexttrue to exit the synchronization domain for the context before the wait (if in a synchronized context), and reacquire it afterward; otherwise, false.
Returns
true if the current instance receives a signal; otherwise, false.
Exceptions
T:System.ObjectDisposedExceptionThe current instance has already been disposed.
T:System.ArgumentOutOfRangeExceptionmillisecondsTimeout is a negative number other than -1, which represents an infinite time-out.
T:System.Threading.AbandonedMutexExceptionThe wait completed because a thread exited without releasing a mutex. This exception is not thrown on Windows 98 or Windows Millennium Edition.
T:System.InvalidOperationExceptionThe current instance is a transparent proxy for a T:System.Threading.WaitHandle in another application domain.

Definition at line 162 of file WaitHandle.cs.

◆ WaitOne() [2/5]

virtual bool System.Threading.WaitHandle.WaitOne ( TimeSpan  timeout,
bool  exitContext 
)
virtual

Blocks the current thread until the current instance receives a signal, using a T:System.TimeSpan to specify the time interval and specifying whether to exit the synchronization domain before the wait.

Parameters
timeoutA T:System.TimeSpan that represents the number of milliseconds to wait, or a T:System.TimeSpan that represents -1 milliseconds to wait indefinitely.
exitContexttrue to exit the synchronization domain for the context before the wait (if in a synchronized context), and reacquire it afterward; otherwise, false.
Returns
true if the current instance receives a signal; otherwise, false.
Exceptions
T:System.ObjectDisposedExceptionThe current instance has already been disposed.
T:System.ArgumentOutOfRangeExceptiontimeout is a negative number other than -1 milliseconds, which represents an infinite time-out.-or-

timeout is greater than F:System.Int32.MaxValue.

Exceptions
T:System.Threading.AbandonedMutexExceptionThe wait completed because a thread exited without releasing a mutex. This exception is not thrown on Windows 98 or Windows Millennium Edition.
T:System.InvalidOperationExceptionThe current instance is a transparent proxy for a T:System.Threading.WaitHandle in another application domain.

Definition at line 184 of file WaitHandle.cs.

◆ WaitOne() [3/5]

virtual bool System.Threading.WaitHandle.WaitOne ( )
virtual

Blocks the current thread until the current T:System.Threading.WaitHandle receives a signal.

Returns
true if the current instance receives a signal. If the current instance is never signaled, M:System.Threading.WaitHandle.WaitOne(System.Int32,System.Boolean) never returns.
Exceptions
T:System.ObjectDisposedExceptionThe current instance has already been disposed.
T:System.Threading.AbandonedMutexExceptionThe wait completed because a thread exited without releasing a mutex. This exception is not thrown on Windows 98 or Windows Millennium Edition.
T:System.InvalidOperationExceptionThe current instance is a transparent proxy for a T:System.Threading.WaitHandle in another application domain.

Definition at line 201 of file WaitHandle.cs.

◆ WaitOne() [4/5]

virtual bool System.Threading.WaitHandle.WaitOne ( int  millisecondsTimeout)
virtual

Blocks the current thread until the current T:System.Threading.WaitHandle receives a signal, using a 32-bit signed integer to specify the time interval in milliseconds.

Parameters
millisecondsTimeoutThe number of milliseconds to wait, or F:System.Threading.Timeout.Infinite (-1) to wait indefinitely.
Returns
true if the current instance receives a signal; otherwise, false.
Exceptions
T:System.ObjectDisposedExceptionThe current instance has already been disposed.
T:System.ArgumentOutOfRangeExceptionmillisecondsTimeout is a negative number other than -1, which represents an infinite time-out.
T:System.Threading.AbandonedMutexExceptionThe wait completed because a thread exited without releasing a mutex. This exception is not thrown on Windows 98 or Windows Millennium Edition.
T:System.InvalidOperationExceptionThe current instance is a transparent proxy for a T:System.Threading.WaitHandle in another application domain.

Definition at line 216 of file WaitHandle.cs.

◆ WaitOne() [5/5]

virtual bool System.Threading.WaitHandle.WaitOne ( TimeSpan  timeout)
virtual

Blocks the current thread until the current instance receives a signal, using a T:System.TimeSpan to specify the time interval.

Parameters
timeoutA T:System.TimeSpan that represents the number of milliseconds to wait, or a T:System.TimeSpan that represents -1 milliseconds to wait indefinitely.
Returns
true if the current instance receives a signal; otherwise, false.
Exceptions
T:System.ObjectDisposedExceptionThe current instance has already been disposed.
T:System.ArgumentOutOfRangeExceptiontimeout is a negative number other than -1 milliseconds, which represents an infinite time-out.-or- timeout is greater than F:System.Int32.MaxValue.
T:System.Threading.AbandonedMutexExceptionThe wait completed because a thread exited without releasing a mutex. This exception is not thrown on Windows 98 or Windows Millennium Edition.
T:System.InvalidOperationExceptionThe current instance is a transparent proxy for a T:System.Threading.WaitHandle in another application domain.

Definition at line 232 of file WaitHandle.cs.

Member Data Documentation

◆ InvalidHandle

readonly IntPtr System.Threading.WaitHandle.InvalidHandle = GetInvalidHandle()
staticprotected

Represents an invalid native operating system handle. This field is read-only.

Definition at line 39 of file WaitHandle.cs.

◆ WaitTimeout

const int System.Threading.WaitHandle.WaitTimeout = 258

Indicates that a M:System.Threading.WaitHandle.WaitAny(System.Threading.WaitHandle[],System.Int32,System.Boolean) operation timed out before any of the wait handles were signaled. This field is constant.

Definition at line 27 of file WaitHandle.cs.

Property Documentation

◆ Handle

virtual IntPtr System.Threading.WaitHandle.Handle
getset

Gets or sets the native operating system handle.

Returns
An IntPtr representing the native operating system handle. The default is the value of the F:System.Threading.WaitHandle.InvalidHandle field.

Definition at line 53 of file WaitHandle.cs.

◆ SafeWaitHandle

SafeWaitHandle System.Threading.WaitHandle.SafeWaitHandle
getset

Gets or sets the native operating system handle.

Returns
A T:Microsoft.Win32.SafeHandles.SafeWaitHandle representing the native operating system handle.

Definition at line 86 of file WaitHandle.cs.


The documentation for this class was generated from the following file: