ReaderWriterLockSlim.RecursionPolicy 屬性

定義

取得值,表示目前 ReaderWriterLockSlim 物件的遞迴原則。Gets a value that indicates the recursion policy for the current ReaderWriterLockSlim object.

public:
 property System::Threading::LockRecursionPolicy RecursionPolicy { System::Threading::LockRecursionPolicy get(); };
public System.Threading.LockRecursionPolicy RecursionPolicy { get; }
member this.RecursionPolicy : System.Threading.LockRecursionPolicy
Public ReadOnly Property RecursionPolicy As LockRecursionPolicy

屬性值

一個列舉值,指定鎖定遞迴原則。One of the enumeration values that specifies the lock recursion policy.

備註

遞迴原則會決定多次輸入鎖定的執行緒限制。Recursion policy determines the restrictions on threads that enter the lock more than once. 例如, 如果已使用LockRecursionPolicy.NoRecursion建立鎖定, 而執行緒已進入讀取模式的鎖定, 則如果執行緒嘗試在讀取模式中重新輸入鎖定, LockRecursionException就會擲回。For example, if a lock was created with LockRecursionPolicy.NoRecursion and a thread has entered the lock in read mode, LockRecursionException is thrown if the thread tries to reenter the lock in read mode.

注意

無論鎖定遞迴原則設定為何, 處於可升級模式的執行緒都可以升級至寫入模式或降級為讀取模式。A thread in upgradeable mode can upgrade to write mode or downgrade to read mode regardless of the lock recursion policy setting.

無論遞迴原則為何, 一開始進入讀取模式的執行緒都不允許升級至可升級模式或寫入模式, 因為該模式會產生極大的鎖死機率。Regardless of recursion policy, a thread that initially entered read mode is not allowed to upgrade to upgradeable mode or write mode, because that pattern creates a strong probability of deadlocks.

如需遞迴原則及其效果的詳細資訊, 請參閱LockRecursionPolicy列舉ReaderWriterLockSlim和類別。For more information about recursion policy and its effects, see the LockRecursionPolicy enumeration and the ReaderWriterLockSlim class.

適用於

另請參閱