Class AsyncBridge
Allows to turn WaitHandle and CancellationToken into task.
Inherited Members
Namespace: DotNext.Threading
Assembly: DotNext.Threading.dll
Syntax
public static class AsyncBridge
Properties
| Edit this page View SourceMaxPoolSize
Gets or sets the capacity of the internal pool used to create awaitable tasks returned from the public methods in this class.
Declaration
public static int MaxPoolSize { get; set; }
Property Value
Type | Description |
---|---|
int |
Methods
| Edit this page View SourceWaitAsync(CancellationToken, bool)
Obtains a task that can be used to await token cancellation.
Declaration
public static ValueTask WaitAsync(this CancellationToken token, bool completeAsCanceled = false)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | token | The token to be converted into task. |
bool | completeAsCanceled | true to complete task in Canceled state; false to complete task in RanToCompletion state. |
Returns
Type | Description |
---|---|
ValueTask | A task representing token state. |
Exceptions
Type | Condition |
---|---|
ArgumentException |
|
WaitAsync(WaitHandle)
Obtains a task that can be used to await handle completion.
Declaration
public static ValueTask<bool> WaitAsync(this WaitHandle handle)
Parameters
Type | Name | Description |
---|---|---|
WaitHandle | handle | The handle to await. |
Returns
Type | Description |
---|---|
ValueTask<bool> | The task that will be completed . |
WaitAsync(WaitHandle, TimeSpan)
Obtains a task that can be used to await handle completion.
Declaration
public static ValueTask<bool> WaitAsync(this WaitHandle handle, TimeSpan timeout)
Parameters
Type | Name | Description |
---|---|---|
WaitHandle | handle | The handle to await. |
TimeSpan | timeout | The timeout used to await completion. |
Returns
Type | Description |
---|---|
ValueTask<bool> | true if handle is signaled; otherwise, false if timeout occurred. |