Class AsyncAutoResetEvent
Represents asynchronous version of AutoResetEvent.
Inherited Members
Namespace: DotNext.Threading
Assembly: DotNext.Threading.dll
Syntax
public class AsyncAutoResetEvent : QueuedSynchronizer, IAsyncResetEvent, IAsyncEvent, IDisposable, IResettable
Constructors
| Edit this page View SourceAsyncAutoResetEvent(bool)
Initializes a new asynchronous reset event in the specified state.
Declaration
public AsyncAutoResetEvent(bool initialState)
Parameters
Type | Name | Description |
---|---|---|
bool | initialState | true to set the initial state signaled; false to set the initial state to non signaled. |
AsyncAutoResetEvent(bool, int)
Initializes a new asynchronous reset event in the specified state.
Declaration
public AsyncAutoResetEvent(bool initialState, int concurrencyLevel)
Parameters
Type | Name | Description |
---|---|---|
bool | initialState | true to set the initial state signaled; false to set the initial state to non signaled. |
int | concurrencyLevel | The expected number of concurrent flows. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException |
|
Properties
| Edit this page View SourceIsSet
Indicates whether this event is set.
Declaration
public bool IsSet { get; }
Property Value
Type | Description |
---|---|
bool |
Methods
| Edit this page View SourceReset()
Sets the state of this event to non signaled, causing consumers to wait asynchronously.
Declaration
public bool Reset()
Returns
Type | Description |
---|---|
bool |
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | The current instance has already been disposed. |
Set()
Sets the state of the event to signaled, resuming the suspended caller.
Declaration
public bool Set()
Returns
Type | Description |
---|---|
bool |
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | The current instance has already been disposed. |
Wait(TimeSpan)
Blocks the current thread until this event is set.
Declaration
public bool Wait(TimeSpan timeout)
Parameters
Type | Name | Description |
---|---|---|
TimeSpan | timeout | The time to wait for the event. |
Returns
Type | Description |
---|---|
bool |
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | The current instance has already been disposed. |
ArgumentOutOfRangeException |
|
WaitAsync(CancellationToken)
Turns caller into idle state until the current event is set.
Declaration
public ValueTask WaitAsync(CancellationToken token = default)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | token | The token that can be used to abort wait process. |
Returns
Type | Description |
---|---|
ValueTask | The task representing asynchronous result. |
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | The current instance has already been disposed. |
OperationCanceledException | The operation has been canceled. |
WaitAsync(TimeSpan, CancellationToken)
Turns caller into idle state until the current event is set.
Declaration
public ValueTask<bool> WaitAsync(TimeSpan timeout, CancellationToken token = default)
Parameters
Type | Name | Description |
---|---|---|
TimeSpan | timeout | The interval to wait for the signaled state. |
CancellationToken | token | The token that can be used to abort wait process. |
Returns
Type | Description |
---|---|
ValueTask<bool> |
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | The current instance has already been disposed. |
ArgumentOutOfRangeException |
|
OperationCanceledException | The operation has been canceled. |