Allows to turn WaitHandle and CancellationToken into task.
Namespace: DotNext.Threading Assembly: DotNext.Threading.dll Syntaxpublic static class AsyncBridge
Properties | Edit this page View Source MaxPoolSize
Gets or sets the capacity of the internal pool used to create awaitable tasks returned from the public methods in this class.
Declarationpublic static int MaxPoolSize { get; set; }
Property Value Methods | Edit this page View Source AsCancellationToken(Task)
Returns a cancellation token that gets signaled when the task completes.
Declarationpublic static CancellationToken AsCancellationToken(this Task task)
Parameters Type Name Description Task task
The task to observe.
Returns Type Description CancellationTokenThe token that represents completion state of the task.
Exceptions | Edit this page View Source AsCancellationToken(Task, out Func<bool>)Returns a cancellation token that gets signaled when the task completes.
Declarationpublic static CancellationToken AsCancellationToken(this Task task, out Func<bool> disposeTokenSource)
Parameters Type Name Description Task task
The task to observe.
Func<bool> disposeTokenSourceA delegate that can be used to destroy the source of the returned token if no longer needed. It returns true if token was not canceled by the task; otherwise, false.
Returns Type Description CancellationTokenThe token that represents completion state of the task.
Exceptions | Edit this page View Source WaitAnyAsync(ReadOnlySpan<CancellationToken>)Creates a task that will complete when any of the supplied tokens have canceled.
Declarationpublic static Task<CancellationToken> WaitAnyAsync(this ReadOnlySpan<CancellationToken> tokens)
Parameters Returns Exceptions | Edit this page View Source WaitAnyAsync(ReadOnlySpan<CancellationToken>, out Func<object?, bool>)
Creates a task that will complete when any of the supplied tokens have canceled.
Declarationpublic static Task<CancellationToken> WaitAnyAsync(this ReadOnlySpan<CancellationToken> tokens, out Func<object?, bool> interruption)
Parameters Type Name Description ReadOnlySpan<CancellationToken> tokens
The tokens to wait on for cancellation.
Func<object, bool> interruptionAn interruption procedure than can be used to turn the returned task into the failed state.
Returns Exceptions | Edit this page View Source WaitAsync(CancellationToken, bool)Obtains a task that can be used to await token cancellation.
Declarationpublic static ValueTask WaitAsync(this CancellationToken token, bool completeAsCanceled = false)
Parameters Returns Type Description ValueTask
A task representing token state.
Exceptions | Edit this page View Source WaitAsync(WaitHandle, CancellationToken)Obtains a task that can be used to await handle completion.
Declarationpublic static ValueTask WaitAsync(this WaitHandle handle, CancellationToken token = default)
Parameters Type Name Description WaitHandle handle
The handle to await.
CancellationToken tokenThe token that can be used to cancel the operation.
Returns Type Description ValueTaskThe task that will be completed .
Exceptions | Edit this page View Source WaitAsync(WaitHandle, TimeSpan, CancellationToken)Obtains a task that can be used to await handle completion.
Declarationpublic static ValueTask<bool> WaitAsync(this WaitHandle handle, TimeSpan timeout, CancellationToken token = default)
Parameters Type Name Description WaitHandle handle
The handle to await.
TimeSpan timeoutThe timeout used to await completion.
CancellationToken tokenThe token that can be used to cancel the operation.
Returns ExceptionsRetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4