Bagikan melalui


Monitor.PulseAll Method

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Notifies all waiting threads of a change in the object's state.

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

Syntax

'Declaration
<SecuritySafeCriticalAttribute> _
Public Shared Sub PulseAll ( _
    obj As Object _
)
[SecuritySafeCriticalAttribute]
public static void PulseAll(
    Object obj
)

Parameters

Exceptions

Exception Condition
ArgumentNullException

The obj parameter is nulla null reference (Nothing in Visual Basic).

SynchronizationLockException

The calling thread does not own the lock for the specified object.

Remarks

The thread that currently owns the lock on the specified object invokes this method to signal all threads waiting to acquire the lock on the object. After the signal is sent, the waiting threads are moved to the ready queue. When the thread that invoked PulseAll releases the lock, the next thread in the ready queue acquires 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 remarks for the Pulse method explain what happens if Pulse is called when no threads are waiting.

To signal a single thread, use the Pulse method.

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.