DotNext.Threading by .NET Foundation and Contributors

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

 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 = 0)

Initializes a new asynchronous counter.

public void Increment()

Increments counter and resume suspended callers.

public bool TryDecrement()

Attempts to decrement the counter synchronously.

public Task<bool> WaitAsync(TimeSpan timeout, CancellationToken token)

Suspends caller if Value is zero or just decrements it.