System.Threading.ReaderWriterLockSlim.EnterReadLock Method

Tries to enter the lock in read mode.

Syntax

public void EnterReadLock ()

Remarks

This method blocks until the calling thread enters the lock, and therefore might never return. Use the erload:System.Threading.ReaderWriterLockSlim.TryEnterReadLock method to block for a specified interval, and then return if the calling thread has not entered read mode during that interval.

Multiple threads can enter read mode at the same time.

If one or more threads are waiting to enter write mode, a thread that calls the ReaderWriterLockSlim.EnterReadLock method blocks until those threads have either timed out or entered write mode and then exited from it.

Note:

If a lock allows recursion, a thread that has entered the lock in read mode can enter read mode recursively, even if other threads are waiting to enter write mode.

At most one thread can be in upgradeable mode while other threads are in read mode. If additional threads are waiting to enter upgradeable mode, and there are no threads waiting to enter write mode, threads that call the ReaderWriterLockSlim.EnterReadLock method enter read mode immediately and do not block.

Requirements

Namespace: System.Threading
Assembly: System.Core (in System.Core.dll)
Assembly Versions: 4.0.0.0