NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

ThreadPool.RegisterWaitForSingleObject

Registers an object so that when the time-out occurs the delegate is called.

The RegisterWaitForSingleObject method queues the specified delegate to the thread pool. A worker thread will execute the delegate when one of the following occurs:

The RegisterWaitForSingleObject method checks the current state of the specified object WaitHandle. If the object's state is nonsignaled, the method registers a wait operation. The wait operation is performed by a thread from the system thread pool. The delegate is executed by a worker thread when the object's state becomes signaled or the time-out interval elapses. If timeOutInterval is not zero and executeOnlyOnce is not false, the timer is reset every time the event is signaled or the time-out interval elapses.

To cancel the wait operation, call the TBD method. Do not make a blocking System.Threading.RegisteredWaitHandle.Unregister call within the delegate.

The wait thread uses the WaitForMultipleObjects function to monitor registered wait operations. Therefore, if you must use the same native OS handle in multiple calls to RegisterWaitForSingleObject, you must duplicate the handle using the Win32 DuplicateHandle function. Note that you should not pulse an event object passed to RegisterWaitForSingleObject, because the wait thread might not detect that the event is signaled before it is reset.

Before returning, the function modifies the state of some types of synchronization objects. Modification occurs only for the object whose signaled state caused the wait condition to be satisfied. For example, the count of a semaphore object is decreased by one.

The RegisterWaitForSingleObject method can wait for the following objects:

Overload List

Registers an object.

[Visual Basic] Overloads Public Shared Function RegisterWaitForSingleObject(WaitHandle, WaitOrTimerCallback, Object, UInt32, Boolean) As RegisteredWaitHandle
[C#] public static RegisteredWaitHandle RegisterWaitForSingleObject(WaitHandle, WaitOrTimerCallback, Object, uint, bool);
[C++] public: static RegisteredWaitHandle* RegisterWaitForSingleObject(WaitHandle*, WaitOrTimerCallback, Object, unsigned int, bool);
[JScript] public static function RegisterWaitForSingleObject(WaitHandle, WaitOrTimerCallback, Object, UInt32, Boolean) : RegisteredWaitHandle;

Registers an object.

[Visual Basic] Overloads Public Shared Function RegisterWaitForSingleObject(WaitHandle, WaitOrTimerCallback, Object, Integer, Boolean) As RegisteredWaitHandle
[C#] public static RegisteredWaitHandle RegisterWaitForSingleObject(WaitHandle, WaitOrTimerCallback, Object, int, bool);
[C++] public: static RegisteredWaitHandle* RegisterWaitForSingleObject(WaitHandle*, WaitOrTimerCallback, Object, int, bool);
[JScript] public static function RegisterWaitForSingleObject(WaitHandle, WaitOrTimerCallback, Object, int, Boolean) : RegisteredWaitHandle;

Registers an object.

[Visual Basic] Overloads Public Shared Function RegisterWaitForSingleObject(WaitHandle, WaitOrTimerCallback, Object, TimeSpan, Boolean) As RegisteredWaitHandle
[C#] public static RegisteredWaitHandle RegisterWaitForSingleObject(WaitHandle, WaitOrTimerCallback, Object, TimeSpan, bool);
[C++] public: static RegisteredWaitHandle* RegisterWaitForSingleObject(WaitHandle*, WaitOrTimerCallback, Object, TimeSpan, bool);
[JScript] public static function RegisterWaitForSingleObject(WaitHandle, WaitOrTimerCallback, Object, TimeSpan, Boolean) : RegisteredWaitHandle;

Registers an object.

[Visual Basic] Overloads Public Shared Function RegisterWaitForSingleObject(WaitHandle, WaitOrTimerCallback, Object, Long, Boolean) As RegisteredWaitHandle
[C#] public static RegisteredWaitHandle RegisterWaitForSingleObject(WaitHandle, WaitOrTimerCallback, Object, long, bool);
[C++] public: static RegisteredWaitHandle* RegisterWaitForSingleObject(WaitHandle*, WaitOrTimerCallback, Object, __int64, bool);
[JScript] public static function RegisterWaitForSingleObject(WaitHandle, WaitOrTimerCallback, Object, long, Boolean) : RegisteredWaitHandle;

See Also

ThreadPool Class | ThreadPool Members | System.Threading Namespace