ReaderWriterLockSlim.IsWriteLockHeld Propriedade

Definição

Obtém um valor que indica se o thread atual inseriu o bloqueio no modo de gravação.Gets a value that indicates whether the current thread has entered the lock in write mode.

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

Valor da propriedade

Boolean

true Se o thread atual tiver entrado no modo de gravação; caso contrário, false .true if the current thread has entered write mode; otherwise, false.

Exemplos

O exemplo a seguir mostra como usar a IsWriteLockHeld propriedade para gerar uma declaração se o thread atual entrou no modo de gravação inesperadamente.The following example shows how to use the IsWriteLockHeld property to generate an assert if the current thread has entered write mode unexpectedly.

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))

Comentários

Esta propriedade destina-se ao uso em asserções ou para outras finalidades de depuração.This property is intended for use in asserts or for other debugging purposes. Não use-o para controlar o fluxo de execução do programa.Do not use it to control the flow of program execution.

Aplica-se a