DotNext.Threading by .NET Foundation and Contributors

<PackageReference Include="DotNext.Threading" Version="4.12.3" />

 AsyncCounter

Represents a synchronization primitive that is signaled when its count becomes non zero.
public long Value { get; }

Gets the counter value.

public AsyncCounter(long initialValue, int concurrencyLevel)

Initializes a new asynchronous counter.

public AsyncCounter(long initialValue = 0)

Initializes a new asynchronous counter.

public void Increment()

Increments counter and resume suspended callers.

public void Increment(long delta)

Increments counter and resume suspended callers.

public bool TryDecrement()

Attempts to decrement the counter synchronously.

public ValueTask<bool> WaitAsync(TimeSpan timeout, CancellationToken token = default)

Suspends caller if Value is zero or just decrements it.

public ValueTask WaitAsync(CancellationToken token = default)

Suspends caller if Value is zero or just decrements it.