Condividi tramite


ReaderWriterLockSlim.IsWriteLockHeld Proprietà

Definizione

Ottiene un valore che indica se il thread corrente ha immesso il blocco in modalità scrittura.

public:
 property bool IsWriteLockHeld { bool get(); };
public bool IsWriteLockHeld { get; }
member this.IsWriteLockHeld : bool
Public ReadOnly Property IsWriteLockHeld As Boolean

Valore della proprietà

true se il thread corrente è entrato in modalità di scrittura; in caso contrario, false.

Esempio

Nell'esempio seguente viene illustrato come utilizzare la IsWriteLockHeld proprietà per generare un'asserzione se il thread corrente è entrato in modalità di scrittura in modo imprevisto.

using (ReaderWriterLockSlim rwLock = new ReaderWriterLockSlim()) {
Using rwLock As New ReaderWriterLockSlim()
Debug.Assert(!rwLock.IsWriteLockHeld, 
    String.Format("Thread {0} is still holding the write lock after MyFunction has finished.", 
                  Thread.CurrentThread.ManagedThreadId));
Debug.Assert(Not rwLock.IsWriteLockHeld, _
    String.Format("Thread {0} is still holding the write lock after MyFunction has finished.", _
                  Thread.CurrentThread.ManagedThreadId))

Commenti

Questa proprietà è destinata all'uso in asserzioni o per altri scopi di debug. Non usarlo per controllare il flusso di esecuzione del programma.

Si applica a