DotNext.Threading by .NET Foundation and Contributors

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

 AsyncCorrelationSource<TKey, TValue>

public class AsyncCorrelationSource<TKey, TValue>
Represents pub/sub synchronization primitive when each event has unique identifier.
public AsyncCorrelationSource(long concurrencyLevel, IEqualityComparer<TKey> comparer = null)

Initializes a new event correlation source.

public void ClearCache()

Removes all cached tasks.

public bool Pulse(TKey eventId, TValue value)

Informs that the event is occurred.

public void PulseAll(TValue value)

Notifies all active listeners.

public void PulseAll(Exception e)

Raises the exception on all active listeners.

public void PulseAll(CancellationToken token)

Cancels all active listeners.

public ValueTask<TValue> WaitAsync(TKey eventId, TimeSpan timeout, CancellationToken token = default)

Returns the task linked with the specified event identifier.

public ValueTask<TValue> WaitAsync(TKey eventId, CancellationToken token = default)

Returns the task linked with the specified event identifier.