System.Threading.ReaderWriterLockSlim.EnterUpgradeableReadLock Method

Tries to enter the lock in upgradeable mode.

Syntax

public void EnterUpgradeableReadLock ()

Remarks

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

Use upgradeable mode when a thread usually accesses the resource that is protected by the System.Threading.ReaderWriterLockSlim in read mode, but may need to enter write mode if certain conditions are met. A thread in upgradeable mode can downgrade to read mode or upgrade to write mode.

Only one thread can enter upgradeable mode at any given time. If a thread is in upgradeable mode, and there are no threads waiting to enter write mode, any number of other threads can enter read mode, even if there are threads waiting to enter upgradeable mode.

If one or more threads are waiting to enter write mode, a thread that calls the ReaderWriterLockSlim.EnterUpgradeableReadLock 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 upgradeable mode can enter upgradeable mode recursively, even if other threads are waiting to enter write mode.

Requirements

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