Class AsyncCountdownEvent
Represents a synchronization primitive that is signaled when its count reaches zero.
Inherited Members
Namespace: DotNext.Threading
Assembly: DotNext.Threading.dll
Syntax
public class AsyncCountdownEvent : QueuedSynchronizer, IAsyncEvent
Remarks
This is asynchronous version of CountdownEvent.
Constructors
| Improve this Doc View SourceAsyncCountdownEvent(Int64)
Creates a new countdown event with the specified count.
Declaration
public AsyncCountdownEvent(long initialCount)
Parameters
Type | Name | Description |
---|---|---|
Int64 | initialCount | The number of signals initially required to set the event. |
AsyncCountdownEvent(Int64, Int32)
Creates a new countdown event with the specified count.
Declaration
public AsyncCountdownEvent(long initialCount, int concurrencyLevel)
Parameters
Type | Name | Description |
---|---|---|
Int64 | initialCount | The number of signals initially required to set the event. |
Int32 | concurrencyLevel | The expected number of suspended callers. |
Properties
| Improve this Doc View SourceCurrentCount
Gets the number of remaining signals required to set the event.
Declaration
public long CurrentCount { get; }
Property Value
Type | Description |
---|---|
Int64 |
InitialCount
Gets the numbers of signals initially required to set the event.
Declaration
public long InitialCount { get; }
Property Value
Type | Description |
---|---|
Int64 |
IsSet
Indicates whether this event is set.
Declaration
public bool IsSet { get; }
Property Value
Type | Description |
---|---|
Boolean |
Methods
| Improve this Doc View SourceAddCount()
Increments the current count by one.
Declaration
public void AddCount()
AddCount(Int64)
Increments the current count by a specified value.
Declaration
public void AddCount(long signalCount)
Parameters
Type | Name | Description |
---|---|---|
Int64 | signalCount | The value by which to increase CurrentCount. |
Reset()
Resets the CurrentCount to the value of InitialCount.
Declaration
public bool Reset()
Returns
Type | Description |
---|---|
Boolean | true, if state of this object changed from signaled to non-signaled state; otherwise, false. |
Reset(Int64)
Resets the InitialCount property to a specified value.
Declaration
public bool Reset(long count)
Parameters
Type | Name | Description |
---|---|---|
Int64 | count | The number of signals required to set this event. |
Returns
Type | Description |
---|---|
Boolean | true, if state of this object changed from signaled to non-signaled state; otherwise, false. |
Signal(Int64)
Registers multiple signals with this object, decrementing the value of CurrentCount by the specified amount.
Declaration
public bool Signal(long signalCount = 1L)
Parameters
Type | Name | Description |
---|---|---|
Int64 | signalCount | The number of signals to register. |
Returns
Type | Description |
---|---|
Boolean | true if the signals caused the count to reach zero and the event was set; otherwise, false. |
TryAddCount()
Attempts to increment the current count by one.
Declaration
public bool TryAddCount()
Returns
Type | Description |
---|---|
Boolean | true if the increment succeeded; if CurrentCount is already at zero this will return false. |
TryAddCount(Int64)
Attempts to increment the current count by a specified value.
Declaration
public bool TryAddCount(long signalCount)
Parameters
Type | Name | Description |
---|---|---|
Int64 | signalCount | The value by which to increase CurrentCount. |
Returns
Type | Description |
---|---|
Boolean | true if the increment succeeded; if CurrentCount is already at zero this will return 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. |
Explicit Interface Implementations
| Improve this Doc View SourceIAsyncEvent.Signal()
Declaration
bool IAsyncEvent.Signal()
Returns
Type | Description |
---|---|
Boolean |