WaitTimeout Field
Collapse the table of content
Expand the table of content

WaitHandle.WaitTimeout Field

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Indicates that a WaitAny operation timed out before any of the wait handles were signaled. This field is constant.

Namespace:  System.Threading
Assembly:  mscorlib (in mscorlib.dll)

public const int WaitTimeout

This field is one of the possible return values of WaitAny.

The following example shows how to use the WaitTimeout field with the WaitAny(WaitHandle[], Int32) method overload to report progress while waiting for multiple threads to finish. Each time the WaitAny method times out, the thread that was waiting reports progress to the user interface thread.

This code is part of a larger example provided for the WaitHandle class.


// Wait for ANY subtask to complete, and show progress.

// Create an array of ManualResetEvent wait handles. Each subtask will
// signal its ManualResetEvent when it is finished.
WaitHandle[] waitHandles = finished.ToArray();
int index = WaitHandle.WaitTimeout;

while (index == WaitHandle.WaitTimeout)
{
   // Wait for any WaitHandle to be signaled. Use a timeout of 250 milliseconds 
   // to send progress reports. If a timeout occurs, WaitTimeout is returned;
   // if a WaitHandle signals, the array index of the WaitHandle is returned.
   //
   index = WaitHandle.WaitAny(waitHandles, 250);
   worker.ReportProgress(1);
}


Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2017 Microsoft