Sends a notification to all waiting objects.
[Visual Basic] Public Shared Sub PulseAll( _ ByVal obj As Object _ ) [C#] public static void PulseAll( object obj ); [C++] public: static void PulseAll( Object* obj ); [JScript] public static function PulseAll( obj : Object );
Exception Type | Condition |
---|---|
ArgumentNullException | If obj is a null reference (in Visual Basic Nothing). |
SynchronizationLockException | If this method is not called inside a synchronized block of code. |
The thread that currently holds the lock on this object invokes this method in order to Pulse all of the threads in the waiting queue of a change in the object's state. Shortly after the call to PulseAll, the threads in the waiting queue are moved to the ready queue, the thread that invoked PulseAll releases the lock, and the next thread (if there is one) in the ready queue is allowed to take control of the lock.
Note that a synchronized object holds several references, including a reference to the thread that currently holds the lock, a reference to the ready queue, which contains the threads that are ready to obtain the lock, and a reference to the waiting queue, which contains the threads that are waiting for notification of a change in the object's state. The Pulse, PulseAll, and Wait methods must be invoked from within a synchronized block of code. The examples in the description for Wait(Object, Int32) resolve an issue that arises when Pulse is invoked before Wait.
Monitor Class | Monitor Members | System.Threading Namespace | Thread