Class AsyncUtils
A set of utilities around and for better asynchronous behavior.
Assembly: Dalamud.dll
View Source
public static class AsyncUtils
Methods
FirstSuccessfulTask<T>(ICollection<Task<T>>)
Race a set of tasks, returning either the first to succeed or an aggregate of all exceptions. This helper does not perform any automatic cancellation of losing tasks, nor does it handle exceptions of losing tasks.
View Source
public static Task<T> FirstSuccessfulTask<T>(ICollection<Task<T>> tasks)
Returns
System.Threading.Tasks.Task<<T>>
: Returns the first task that completes, according to System.Threading.Tasks.Task.IsCompletedSuccessfully
.
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.ICollection<System.Threading.Tasks.Task<<T>>> | tasks | A list of tasks to race. |
Type Parameters
Name | Description |
---|---|
T | The return type of all raced tasks. |
Exceptions
System.AggregateException
Thrown when all tasks given to this method fail.
CancellableDelay(int, CancellationToken)
Provide a System.Threading.Tasks.Task.Delay(System.Int32%2cSystem.Threading.CancellationToken)
that won't throw an exception when it's canceled.
View Source
public static Task CancellableDelay(int millisecondsDelay, CancellationToken cancellationToken)
Returns
System.Threading.Tasks.Task
: A task that represents the time delay.
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | millisecondsDelay | The number of milliseconds to wait before completing the returned task, or -1 to wait indefinitely. |
System.Threading.CancellationToken | cancellationToken | A cancellation token to observe while waiting for the task to complete. |
Exceptions
System.ArgumentOutOfRangeException
The <code class="paramref">millisecondsDelay</code> argument is less than -1.
System.Threading.Tasks.TaskCanceledException
The task has been canceled.
System.ObjectDisposedException
The provided <code class="paramref">cancellationToken</code> has already been disposed.