DevToys logo DevToys
  • Home
  • Blog
  • Documentation
  • Download
Search Results for

    Show / Hide Table of Contents

    Class DisposableSemaphore

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

    Inheritance
    object
    DisposableSemaphore
    Implements
    IDisposable
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: DevToys.Api
    Assembly: DevToys.Api.dll
    Syntax
    public sealed class DisposableSemaphore : IDisposable

    Constructors

    DisposableSemaphore(int)

    Initializes a new instance of the DisposableSemaphore class.

    Declaration
    public DisposableSemaphore(int maxTasksCount = 1)
    Parameters
    Type Name Description
    int maxTasksCount

    The maximum number of concurrent tasks that can be executed.

    Properties

    Disposed

    Gets a value indicating whether the semaphore has been disposed.

    Declaration
    public bool Disposed { get; }
    Property Value
    Type Description
    bool

    IsBusy

    Gets a value indicating whether the semaphore is currently busy.

    Declaration
    public bool IsBusy { get; }
    Property Value
    Type Description
    bool

    Methods

    Dispose()

    Releases all resources used by the DisposableSemaphore.

    Declaration
    public void Dispose()

    WaitAsync(CancellationToken)

    Asynchronously waits for the semaphore to be available.

    Declaration
    public Task<IDisposable> WaitAsync(CancellationToken cancellationToken)
    Parameters
    Type Name Description
    CancellationToken cancellationToken

    The cancellation token.

    Returns
    Type Description
    Task<IDisposable>

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

    Implements

    IDisposable

    Extension Methods

    LoggingExtensions.Log<T>(T)
    In this article
    DevToys logo © 2024 DevToys