Bewerken

Share via


ReaderWriterLockSlim.WaitingUpgradeCount Property

Definition

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

public:
 property int WaitingUpgradeCount { int get(); };
public int WaitingUpgradeCount { get; }
member this.WaitingUpgradeCount : int
Public ReadOnly Property WaitingUpgradeCount As Integer

Property Value

The total number of threads that are waiting to enter upgradeable mode.

Examples

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

using (ReaderWriterLockSlim rwLock = new ReaderWriterLockSlim()) {
Using rwLock As New ReaderWriterLockSlim()
int waitingUpgradeableReadCt = rwLock.WaitingUpgradeCount;
if (waitingUpgradeableReadCt > UPGRADEABLEREAD_THRESHOLD)
{
    performanceLog.WriteEntry(String.Format(
        "{0} blocked upgradeable reader threads; exceeds recommended maximum.", 
        waitingUpgradeableReadCt));
}
Dim waitingUpgradeableReadCt As Integer = rwLock.WaitingUpgradeCount
If waitingUpgradeableReadCt > UPGRADEABLEREAD_THRESHOLD Then
    performanceLog.WriteEntry(String.Format( _
        "{0} blocked upgradeable reader threads; exceeds recommended maximum.", _
        waitingUpgradeableReadCt))
End If

Remarks

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.

Applies to