ReaderWriterLockSlim.IsReadLockHeld Property


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Gets a value that indicates whether the current thread has entered the lock in read mode.

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

public bool IsReadLockHeld { get; }

Property Value

Type: System.Boolean

true if the current thread has entered read mode; otherwise, false.

This property is intended for use in asserts or for other debugging purposes. Do not use it to control the flow of program execution.

The following example shows how to use the IsReadLockHeld property to generate an assert if the current thread has entered read mode unexpectedly.

using (ReaderWriterLockSlim rwLock = new ReaderWriterLockSlim()) {
    String.Format("Thread {0} already held the read lock when MyFunction began executing.",

Universal Windows Platform
Available since 8
.NET Framework
Available since 3.5
Portable Class Library
Supported in: portable .NET platforms
Windows Phone Silverlight
Available since 8.0
Windows Phone
Available since 8.1
Return to top