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
maxTasksCountintThe 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
IsBusy
Gets a value indicating whether the semaphore is currently busy.
public bool IsBusy { get; }
Property Value
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
cancellationTokenCancellationTokenThe cancellation token.
Returns
- Task<IDisposable>
An IDisposable object that should be disposed to release the semaphore.