public enum LockRecursionPolicy
Specifies how to handle reentrant lock acquisitions by the same thread.
System.Threading
System.Runtime.dll
The thread cannot acquire a lock that it already holds. An InvalidOperationException is thrown.
The thread can acquire a lock that it already holds. This is the default behavior.
The LockRecursionPolicy enumeration is used by the ReaderWriterLockSlim class to determine how to treat recursive lock acquisitions.
When a thread attempts to acquire a lock that it already holds, the behavior is determined by the LockRecursionPolicy specified for the ReaderWriterLockSlim instance.
Setting the policy to NoRecursion can help prevent deadlocks caused by unintended recursive lock acquisitions.
However, if your application logic genuinely requires recursive lock acquisitions, you should use the Recursion policy.
LockRecursionPolicy to NoRecursion and a thread attempts to acquire a lock it already holds, an InvalidOperationException will be thrown. This is a safeguard against potential deadlocks.