SynchronizedBlock class

Provides a mechanism that synchronizes access to objects. It is implemented as a thin wrapper on Monitor. During testing, the implementation is automatically replaced with a controlled mocked version. It can be used as a replacement of the lock keyword to allow systematic testing.

public class SynchronizedBlock : IDisposable

Public Members

name description
static Lock(…) Creates a new SynchronizedBlock for synchronizing access to the specified object and enters the lock.
Dispose() Releases resources used by the synchronized block.
virtual Pulse() Notifies a thread in the waiting queue of a change in the locked object’s state.
virtual PulseAll() Notifies all waiting threads of a change in the object’s state.
virtual Wait() Releases the lock on an object and blocks the current thread until it reacquires the lock.
virtual Wait(…) Releases the lock on an object and blocks the current thread until it reacquires the lock. If the specified time-out interval elapses, the thread enters the ready queue. (2 methods)

Protected Members

name description
SynchronizedBlock(…) Initializes a new instance of the SynchronizedBlock class.
readonly SyncObject The object used for synchronization.
virtual Dispose(…) Releases resources used by the synchronized block.
virtual EnterLock() Enters the lock.

See Also