Class AsyncManualResetEvent
Represents asynchronous version of
Inherited Members
Namespace: DotNext.Threading
Assembly: DotNext.Threading.dll
Syntax
public class AsyncManualResetEvent : QueuedSynchronizer, IAsyncResetEvent, IAsyncEvent
Constructors
| Improve this Doc View SourceAsyncManualResetEvent(Boolean)
Initializes a new asynchronous reset event in the specified state.
Declaration
public AsyncManualResetEvent(bool initialState)
Parameters
Type | Name | Description |
---|---|---|
Boolean | initialState | true to set the initial state signaled; false to set the initial state to non signaled. |
AsyncManualResetEvent(Boolean, Int32)
Initializes a new asynchronous reset event in the specified state.
Declaration
public AsyncManualResetEvent(bool initialState, int concurrencyLevel)
Parameters
Type | Name | Description |
---|---|---|
Boolean | initialState | true to set the initial state signaled; false to set the initial state to non signaled. |
Int32 | concurrencyLevel | The potential number of suspended callers. |
Properties
| Improve this Doc View SourceIsSet
Indicates whether this event is set.
Declaration
public bool IsSet { get; }
Property Value
Type | Description |
---|---|
Boolean |
Methods
| Improve this Doc View SourceReset()
Sets the state of this event to non signaled, causing consumers to wait asynchronously.
Declaration
public bool Reset()
Returns
Type | Description |
---|---|
Boolean | true if the operation succeeds; otherwise, false. |
Set()
Sets the state of the event to signaled, allowing one or more awaiters to proceed.
Declaration
public bool Set()
Returns
Type | Description |
---|---|
Boolean | true if the operation succeeds; otherwise, false. |
Set(Boolean)
Sets the state of the event to signaled, allowing one or more awaiters to proceed; and, optionally, reverts the state of the event to initial state.
Declaration
public bool Set(bool autoReset)
Parameters
Type | Name | Description |
---|---|---|
Boolean | autoReset | true to reset this object to non-signaled state automatically; false to leave this object in signaled state. |
Returns
Type | Description |
---|---|
Boolean | true if the operation succeeds; otherwise, false. |
WaitAsync(CancellationToken)
Turns caller into idle state until the current event is set.
Declaration
public ValueTask WaitAsync(CancellationToken token = null)
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. |
WaitAsync(TimeSpan, CancellationToken)
Turns caller into idle state until the current event is set.
Declaration
public ValueTask<bool> WaitAsync(TimeSpan timeout, CancellationToken token = null)
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<Boolean> | true if signaled state was set; otherwise, false. |
WaitAsync<T>(Predicate<T>, T, CancellationToken)
Suspends the caller until this event is set.
Declaration
public ValueTask WaitAsync<T>(Predicate<T> condition, T arg, CancellationToken token = null)
Parameters
Type | Name | Description |
---|---|---|
DotNext.Predicate<T> | condition | Additional condition that must be checked before suspension. |
T | arg | The argument to be passed to the predicate. |
CancellationToken | token | The token that can be used to cancel waiting operation. |
Returns
Type | Description |
---|---|
ValueTask | true, if this event was set; otherwise, false. |
Type Parameters
Name | Description |
---|---|
T | The type of predicate parameter. |
Remarks
If given predicate returns true then caller will not be suspended.
WaitAsync<T>(Predicate<T>, T, TimeSpan, CancellationToken)
Suspends the caller until this event is set.
Declaration
public ValueTask<bool> WaitAsync<T>(Predicate<T> condition, T arg, TimeSpan timeout, CancellationToken token = null)
Parameters
Type | Name | Description |
---|---|---|
DotNext.Predicate<T> | condition | Additional condition that must be checked before suspension. |
T | arg | The argument to be passed to the predicate. |
TimeSpan | timeout | The number of time to wait before this event is set. |
CancellationToken | token | The token that can be used to cancel waiting operation. |
Returns
Type | Description |
---|---|
ValueTask<Boolean> | true, if this event was set; otherwise, false. |
Type Parameters
Name | Description |
---|---|
T | The type of predicate parameter. |
Remarks
If given predicate returns true then caller will not be suspended.
WaitAsync<T1, T2>(Func<T1, T2, Boolean>, T1, T2, CancellationToken)
Suspends the caller until this event is set.
Declaration
public ValueTask WaitAsync<T1, T2>(Func<T1, T2, bool> condition, T1 arg1, T2 arg2, CancellationToken token = null)
Parameters
Type | Name | Description |
---|---|---|
DotNext.Func<T1, T2, Boolean> | condition | Additional condition that must be checked before suspension. |
T1 | arg1 | The first argument to be passed to the predicate. |
T2 | arg2 | The second argument to be passed to the predicate. |
CancellationToken | token | The token that can be used to cancel waiting operation. |
Returns
Type | Description |
---|---|
ValueTask | true, if this event was set; otherwise, false. |
Type Parameters
Name | Description |
---|---|
T1 | The type of the first predicate parameter. |
T2 | The type of the second predicate parameter. |
Remarks
If given predicate returns true then caller will not be suspended.
WaitAsync<T1, T2>(Func<T1, T2, Boolean>, T1, T2, TimeSpan, CancellationToken)
Suspends the caller until this event is set.
Declaration
public ValueTask<bool> WaitAsync<T1, T2>(Func<T1, T2, bool> condition, T1 arg1, T2 arg2, TimeSpan timeout, CancellationToken token = null)
Parameters
Type | Name | Description |
---|---|---|
DotNext.Func<T1, T2, Boolean> | condition | Additional condition that must be checked before suspension. |
T1 | arg1 | The first argument to be passed to the predicate. |
T2 | arg2 | The second argument to be passed to the predicate. |
TimeSpan | timeout | The number of time to wait before this event is set. |
CancellationToken | token | The token that can be used to cancel waiting operation. |
Returns
Type | Description |
---|---|
ValueTask<Boolean> | true, if this event was set; otherwise, false. |
Type Parameters
Name | Description |
---|---|
T1 | The type of the first predicate parameter. |
T2 | The type of the second predicate parameter. |
Remarks
If given predicate returns true then caller will not be suspended.
Explicit Interface Implementations
| Improve this Doc View SourceIAsyncEvent.Signal()
Declaration
bool IAsyncEvent.Signal()
Returns
Type | Description |
---|---|
Boolean |
IAsyncResetEvent.ResetMode
Declaration
EventResetMode IAsyncResetEvent.ResetMode { get; }
Returns
Type | Description |
---|---|
EventResetMode |