This documentation is archived and is not being maintained.

ReaderWriterLockSlim.WaitingReadCount Property

Gets the total number of threads that are waiting to enter the lock in read mode.

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

public int WaitingReadCount { get; }

Property Value

Type: System.Int32
The total number of threads that are waiting to enter read mode.

Use this property only for debugging, profiling, and logging purposes, and not to control the behavior of an algorithm. The results can change as soon as they have been calculated. Therefore, it is not safe to make decisions based on this property.

The following example shows how to use the WaitingReadCount property to generate an event log entry if the number of threads that are blocked, waiting to enter read mode, exceeds a threshold.

ReaderWriterLockSlim rwLock = new ReaderWriterLockSlim();


...


int waitingReadCt = rwLock.WaitingReadCount;
if (waitingReadCt > READ_THRESHOLD)
{
    performanceLog.WriteEntry(String.Format(
        "{0} blocked reader threads; exceeds recommended maximum.", 
        waitingReadCt));
}

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5
Show: