Compartilhar via


AsyncSemaphore Class

Definition

An asynchronous SemaphoreSlim like class with more convenient release syntax.

public ref class AsyncSemaphore : IDisposable
public class AsyncSemaphore : IDisposable
type AsyncSemaphore = class
    interface IDisposable
Public Class AsyncSemaphore
Implements IDisposable
Inheritance
AsyncSemaphore
Implements

Remarks

This semaphore guarantees FIFO ordering.

This object does *not* need to be disposed of, as it does not hold unmanaged resources. Disposing this object has no effect on current users of the semaphore, and they are allowed to release their hold on the semaphore without exception. An ObjectDisposedException is thrown back at anyone asking to or waiting to enter the semaphore after Dispose() is called.

Constructors

AsyncSemaphore(Int32)

Initializes a new instance of the AsyncSemaphore class.

Properties

CurrentCount

Gets the number of openings that remain in the semaphore.

Methods

Dispose()

Faults all pending semaphore waiters with ObjectDisposedException and rejects all subsequent attempts to enter the semaphore with the same exception.

Dispose(Boolean)

Disposes managed and unmanaged resources held by this instance.

EnterAsync(CancellationToken)

Requests access to the lock.

EnterAsync(Int32, CancellationToken)

Requests access to the lock.

EnterAsync(TimeSpan, CancellationToken)

Requests access to the lock.

Applies to

Thread Safety

This type is thread-safe for all members.