Class AsyncEventHub
Represents a collection of asynchronous events.
Inherited Members
Namespace: DotNext.Threading
Assembly: DotNext.Threading.dll
Syntax
public class AsyncEventHub : QueuedSynchronizer, IDisposable, IResettable
Constructors
| Edit this page View SourceAsyncEventHub(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 |
|
Properties
| Edit this page View SourceCount
Gets the number of events.
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
int |
Methods
| Edit this page View SourceCaptureState()
Captures the state of the events.
Declaration
public AsyncEventHub.EventGroup CaptureState()
Returns
Type | Description |
---|---|
AsyncEventHub.EventGroup | A group of signaled events. |
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 |
|
ObjectDisposedException | The object is disposed. |
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 |
|
ObjectDisposedException | The object is disposed. |
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. |
Reset()
Turns all events to non-signaled state.
Declaration
public void Reset()
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | The object is disposed. |
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 |
|
ObjectDisposedException | The object is disposed. |
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 |
|
ObjectDisposedException | The object is disposed. |
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 |
|
OperationCanceledException | The operation has been canceled. |
ObjectDisposedException | The object is disposed. |
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 |
|
TimeoutException | The operation has timed out. |
OperationCanceledException | The operation has been canceled. |
ObjectDisposedException | The object is disposed. |
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. |
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. |
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 |
|
OperationCanceledException | The operation has been canceled. |
ObjectDisposedException | The object is disposed. |
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 |
|
TimeoutException | The operation has timed out. |
OperationCanceledException | The operation has been canceled. |
ObjectDisposedException | The object is disposed. |
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 |
|
OperationCanceledException | The operation has been canceled. |
ObjectDisposedException | The object is disposed. |
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 |
|
TimeoutException | The operation has timed out. |
OperationCanceledException | The operation has been canceled. |
ObjectDisposedException | The object is disposed. |
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. |
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. |
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. |
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. |
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 |
|
ObjectDisposedException | The object is disposed. |
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 |
|
ObjectDisposedException | The object is disposed. |