次の方法で共有


ReentrantSemaphore.ReentrancyMode Enum

Definition

Describes ways the ReentrantSemaphore may behave when a semaphore request is made in a context that is already in the semaphore.

public: enum class ReentrantSemaphore::ReentrancyMode
public enum ReentrantSemaphore.ReentrancyMode
type ReentrantSemaphore.ReentrancyMode = 
Public Enum ReentrantSemaphore.ReentrancyMode
Inheritance
ReentrantSemaphore.ReentrancyMode

Fields

Name Value Description
NotAllowed 0

Reject all requests when the caller has already entered the semaphore (and not yet exited) by throwing an InvalidOperationException.

NotRecognized 1

Each request occupies a unique slot in the semaphore. Reentrancy is not recognized and may lead to deadlocks if the reentrancy level exceeds the count on the semaphore. This resembles the behavior of the AsyncSemaphore class.

Stack 2

A request made by a caller that is already in the semaphore is immediately executed, and shares the same semaphore slot with its parent. This nested request must exit before its parent (Strict LIFO/stack behavior). Exiting the semaphore before a child has or after the parent has will cause an InvalidOperationException to fault the Task returned from ExecuteAsync(Func<Task>, CancellationToken).

Freeform 3

A request made by a caller that is already in the semaphore is immediately executed, and shares the same semaphore slot with its parent. The slot is only released when all requests have exited, which may be in any order.

Applies to