Show / Hide Table of Contents

Class AsyncEventHub

Represents a collection of asynchronous events.

Inheritance
object
Disposable
QueuedSynchronizer
AsyncEventHub
Implements
IDisposable
IResettable
Inherited Members
QueuedSynchronizer.MeasurementTags
QueuedSynchronizer.TrackSuspendedCallers(Func<object>)
QueuedSynchronizer.SetCallerInformation(object)
QueuedSynchronizer.GetSuspendedCallers()
QueuedSynchronizer.CancelSuspendedCallers(CancellationToken)
QueuedSynchronizer.Dispose(bool)
QueuedSynchronizer.Dispose(Exception)
QueuedSynchronizer.DisposeAsyncCore()
QueuedSynchronizer.DisposeAsync()
Disposable.IsDisposed
Disposable.IsDisposing
Disposable.IsDisposingOrDisposed
Disposable.CreateException()
Disposable.DisposedTask
Disposable.GetDisposedTask<T>()
Disposable.TrySetDisposedException<T>(TaskCompletionSource<T>)
Disposable.TrySetDisposedException(TaskCompletionSource)
Disposable.TryBeginDispose()
Disposable.Dispose()
Disposable.Dispose(IEnumerable<IDisposable>)
Disposable.DisposeAsync(IEnumerable<IAsyncDisposable>)
Disposable.Dispose<T>(ReadOnlySpan<T>)
Disposable.DisposeAsync(params IAsyncDisposable[])
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: DotNext.Threading
Assembly: DotNext.Threading.dll
Syntax
public class AsyncEventHub : QueuedSynchronizer, IDisposable, IResettable

Constructors

| Edit this page View Source

AsyncEventHub(int)

Initializes a new collection of asynchronous events.

Declaration
public AsyncEventHub(int count)
Parameters
Type Name Description
int count

The number of asynchronous events.

Exceptions
Type Condition
ArgumentOutOfRangeException

count is less than or equal to zero.

Properties

| Edit this page View Source

Count

Gets the number of events.

Declaration
public int Count { get; }
Property Value
Type Description
int

Methods

| Edit this page View Source

CaptureState()

Captures the state of the events.

Declaration
public AsyncEventHub.EventGroup CaptureState()
Returns
Type Description
AsyncEventHub.EventGroup

A group of signaled events.

| Edit this page View Source

Pulse(in EventGroup)

Turns the specified events into signaled state.

Declaration
public AsyncEventHub.EventGroup Pulse(in AsyncEventHub.EventGroup events)
Parameters
Type Name Description
AsyncEventHub.EventGroup events

A group of events to be signaled.

Returns
Type Description
AsyncEventHub.EventGroup

A group of events set by the method.

Exceptions
Type Condition
ArgumentOutOfRangeException

events contains an event index that is larger than or equal to Count.

ObjectDisposedException

The object is disposed.

| Edit this page View Source

Pulse(int)

Turns an event into the signaled state.

Declaration
public bool Pulse(int eventIndex)
Parameters
Type Name Description
int eventIndex

The index of the event.

Returns
Type Description
bool

true if the event turned into signaled state; false if the event is already in signaled state.

Exceptions
Type Condition
ArgumentOutOfRangeException

eventIndex is invalid.

ObjectDisposedException

The object is disposed.

| Edit this page View Source

PulseAll()

Turns all events into the signaled state.

Declaration
public AsyncEventHub.EventGroup PulseAll()
Returns
Type Description
AsyncEventHub.EventGroup
Exceptions
Type Condition
ObjectDisposedException

The object is disposed.

| Edit this page View Source

Reset()

Turns all events to non-signaled state.

Declaration
public void Reset()
Exceptions
Type Condition
ObjectDisposedException

The object is disposed.

| Edit this page View Source

ResetAndPulse(in EventGroup)

Turns the specified events into signaled state and reset all other events.

Declaration
public AsyncEventHub.EventGroup ResetAndPulse(in AsyncEventHub.EventGroup events)
Parameters
Type Name Description
AsyncEventHub.EventGroup events

A group of events to be signaled.

Returns
Type Description
AsyncEventHub.EventGroup

A group of events set by the method.

Exceptions
Type Condition
ArgumentOutOfRangeException

events contains an event index that is larger than or equal to Count.

ObjectDisposedException

The object is disposed.

| Edit this page View Source

ResetAndPulse(int)

Turns the specified event into the signaled state and reset all other events.

Declaration
public bool ResetAndPulse(int eventIndex)
Parameters
Type Name Description
int eventIndex

The index of the event.

Returns
Type Description
bool

true if the event turned into signaled state; false if the event is already in signaled state.

Exceptions
Type Condition
ArgumentOutOfRangeException

eventIndex is invalid.

ObjectDisposedException

The object is disposed.

| Edit this page View Source

WaitAllAsync(in EventGroup, CancellationToken)

Waits for all events.

Declaration
public ValueTask WaitAllAsync(in AsyncEventHub.EventGroup events, CancellationToken token = default)
Parameters
Type Name Description
AsyncEventHub.EventGroup events

A group of events to be awaited.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask

A task that represents the completion of all the specified events.

Exceptions
Type Condition
ArgumentOutOfRangeException

events contains an event index that is larger than or equal to Count.

OperationCanceledException

The operation has been canceled.

ObjectDisposedException

The object is disposed.

| Edit this page View Source

WaitAllAsync(in EventGroup, TimeSpan, CancellationToken)

Waits for all events.

Declaration
public ValueTask WaitAllAsync(in AsyncEventHub.EventGroup events, TimeSpan timeout, CancellationToken token = default)
Parameters
Type Name Description
AsyncEventHub.EventGroup events

A group of events to be awaited.

TimeSpan timeout

The time to wait for the events.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask

A task that represents the completion of all the specified events.

Exceptions
Type Condition
ArgumentOutOfRangeException

events contains an event index that is larger than or equal to Count.

TimeoutException

The operation has timed out.

OperationCanceledException

The operation has been canceled.

ObjectDisposedException

The object is disposed.

| Edit this page View Source

WaitAllAsync(CancellationToken)

Waits for all events.

Declaration
public ValueTask WaitAllAsync(CancellationToken token = default)
Parameters
Type Name Description
CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask

A task that represents the completion of all the specified events.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

ObjectDisposedException

The object is disposed.

| Edit this page View Source

WaitAllAsync(TimeSpan, CancellationToken)

Waits for all events.

Declaration
public ValueTask WaitAllAsync(TimeSpan timeout, CancellationToken token = default)
Parameters
Type Name Description
TimeSpan timeout

The time to wait for the events.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask

A task that represents the completion of all the specified events.

Exceptions
Type Condition
TimeoutException

The operation has timed out.

OperationCanceledException

The operation has been canceled.

ObjectDisposedException

The object is disposed.

| Edit this page View Source

WaitAnyAsync(in EventGroup, ICollection<int>, CancellationToken)

Waits for any of the specified events.

Declaration
public ValueTask WaitAnyAsync(in AsyncEventHub.EventGroup events, ICollection<int> output, CancellationToken token = default)
Parameters
Type Name Description
AsyncEventHub.EventGroup events

A group of events to be awaited.

ICollection<int> output

A collection of signaled events set by the method when returned successfully.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask

The task representing the event.

Exceptions
Type Condition
ArgumentOutOfRangeException

events contains an event index that is larger than or equal to Count.

OperationCanceledException

The operation has been canceled.

ObjectDisposedException

The object is disposed.

| Edit this page View Source

WaitAnyAsync(in EventGroup, ICollection<int>, TimeSpan, CancellationToken)

Waits for any of the specified events.

Declaration
public ValueTask WaitAnyAsync(in AsyncEventHub.EventGroup events, ICollection<int> output, TimeSpan timeout, CancellationToken token = default)
Parameters
Type Name Description
AsyncEventHub.EventGroup events

A group of events to be awaited.

ICollection<int> output

A collection of signaled events set by the method when returned successfully.

TimeSpan timeout

The time to wait for an event.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask

The task representing the event.

Exceptions
Type Condition
ArgumentOutOfRangeException

events contains an event index that is larger than or equal to Count.

TimeoutException

The operation has timed out.

OperationCanceledException

The operation has been canceled.

ObjectDisposedException

The object is disposed.

| Edit this page View Source

WaitAnyAsync(in EventGroup, CancellationToken)

Waits for any of the specified events.

Declaration
public ValueTask WaitAnyAsync(in AsyncEventHub.EventGroup events, CancellationToken token = default)
Parameters
Type Name Description
AsyncEventHub.EventGroup events

A group of events to be awaited.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask

The task representing the event.

Exceptions
Type Condition
ArgumentOutOfRangeException

events contains an event index that is larger than or equal to Count.

OperationCanceledException

The operation has been canceled.

ObjectDisposedException

The object is disposed.

| Edit this page View Source

WaitAnyAsync(in EventGroup, TimeSpan, CancellationToken)

Waits for any of the specified events.

Declaration
public ValueTask WaitAnyAsync(in AsyncEventHub.EventGroup events, TimeSpan timeout, CancellationToken token = default)
Parameters
Type Name Description
AsyncEventHub.EventGroup events

A group of events to be awaited.

TimeSpan timeout

The time to wait for an event.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask

The task representing the event.

Exceptions
Type Condition
ArgumentOutOfRangeException

events contains an event index that is larger than or equal to Count.

TimeoutException

The operation has timed out.

OperationCanceledException

The operation has been canceled.

ObjectDisposedException

The object is disposed.

| Edit this page View Source

WaitAnyAsync(ICollection<int>, CancellationToken)

Waits for any of the specified events.

Declaration
public ValueTask WaitAnyAsync(ICollection<int> output, CancellationToken token = default)
Parameters
Type Name Description
ICollection<int> output

A collection of signaled events set by the method when returned successfully.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask

The index of the first signaled event.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

ObjectDisposedException

The object is disposed.

| Edit this page View Source

WaitAnyAsync(ICollection<int>, TimeSpan, CancellationToken)

Waits for any of the specified events.

Declaration
public ValueTask WaitAnyAsync(ICollection<int> output, TimeSpan timeout, CancellationToken token = default)
Parameters
Type Name Description
ICollection<int> output

A collection of signaled events set by the method when returned successfully.

TimeSpan timeout

The time to wait for an event.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask

The index of the first signaled event.

Exceptions
Type Condition
TimeoutException

The operation has timed out.

OperationCanceledException

The operation has been canceled.

ObjectDisposedException

The object is disposed.

| Edit this page View Source

WaitAnyAsync(CancellationToken)

Waits for any of the specified events.

Declaration
public ValueTask WaitAnyAsync(CancellationToken token = default)
Parameters
Type Name Description
CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask

The index of the first signaled event.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

ObjectDisposedException

The object is disposed.

| Edit this page View Source

WaitAnyAsync(TimeSpan, CancellationToken)

Waits for any of the specified events.

Declaration
public ValueTask WaitAnyAsync(TimeSpan timeout, CancellationToken token = default)
Parameters
Type Name Description
TimeSpan timeout

The time to wait for an event.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask

The index of the first signaled event.

Exceptions
Type Condition
TimeoutException

The operation has timed out.

OperationCanceledException

The operation has been canceled.

ObjectDisposedException

The object is disposed.

| Edit this page View Source

WaitOneAsync(int, CancellationToken)

Waits for the event represented by the specified index.

Declaration
public ValueTask WaitOneAsync(int eventIndex, CancellationToken token = default)
Parameters
Type Name Description
int eventIndex

The index of the event.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask

The task representing the event.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

ArgumentOutOfRangeException

eventIndex is invalid.

ObjectDisposedException

The object is disposed.

| Edit this page View Source

WaitOneAsync(int, TimeSpan, CancellationToken)

Waits for the event represented by the specified index.

Declaration
public ValueTask WaitOneAsync(int eventIndex, TimeSpan timeout, CancellationToken token = default)
Parameters
Type Name Description
int eventIndex

The index of the event.

TimeSpan timeout

The time to wait for an event.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask

The task representing the event.

Exceptions
Type Condition
TimeoutException

The operation has timed out.

OperationCanceledException

The operation has been canceled.

ArgumentOutOfRangeException

eventIndex is invalid.

ObjectDisposedException

The object is disposed.

Implements

IDisposable
IResettable

Extension Methods

BasicExtensions.As<T>(T)
BasicExtensions.GetUserData<T>(T)
BasicExtensions.IsBetween<T, TLowerBound, TUpperBound>(T, TLowerBound, TUpperBound)
BasicExtensions.IsOneOf<T>(T, ReadOnlySpan<T>)
ExpressionBuilder.Const<T>(T)
AsyncLockAcquisition.AcquireLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireLockAsync<T>(T, TimeSpan, CancellationToken)
AsyncLockAcquisition.AcquireReadLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireReadLockAsync<T>(T, TimeSpan, CancellationToken)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, bool, CancellationToken)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, bool, TimeSpan, CancellationToken)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, TimeSpan, CancellationToken)
LockAcquisition.AcquireReadLock<T>(T)
LockAcquisition.AcquireReadLock<T>(T, TimeSpan)
LockAcquisition.AcquireUpgradeableReadLock<T>(T)
LockAcquisition.AcquireUpgradeableReadLock<T>(T, TimeSpan)
LockAcquisition.AcquireWriteLock<T>(T)
LockAcquisition.AcquireWriteLock<T>(T, TimeSpan)
  • Edit this page
  • View Source
☀
☾
In this article
Back to top
Supported by the .NET Foundation
☀
☾