Table of Contents

Class DisposableSemaphore

Namespace
WindowSill.API
Assembly
WindowSill.API.dll

Represents a semaphore that free other threads when disposing the result of the WaitAsync(CancellationToken) method.

public sealed class DisposableSemaphore : IDisposable
Inheritance
DisposableSemaphore
Implements
Inherited Members
Extension Methods

Remarks

Initializes a new instance of the DisposableSemaphore class.

Constructors

DisposableSemaphore(int)

Represents a semaphore that free other threads when disposing the result of the WaitAsync(CancellationToken) method.

public DisposableSemaphore(int maxTasksCount = 1)

Parameters

maxTasksCount int

The maximum number of concurrent tasks that can be executed.

Remarks

Initializes a new instance of the DisposableSemaphore class.

Properties

Disposed

Gets a value indicating whether the semaphore has been disposed.

public bool Disposed { get; }

Property Value

bool

IsBusy

Gets a value indicating whether the semaphore is currently busy.

public bool IsBusy { get; }

Property Value

bool

Methods

Dispose()

Releases all resources used by the DisposableSemaphore.

public void Dispose()

WaitAsync(CancellationToken)

Asynchronously waits for the semaphore to be available.

public Task<IDisposable> WaitAsync(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

The cancellation token.

Returns

Task<IDisposable>

An IDisposable object that should be disposed to release the semaphore.