Skip to main content

Class AsyncUtils

A set of utilities around and for better asynchronous behavior.

Assembly: Dalamud.dll
Declaration
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.

Declaration
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
TypeNameDescription
System.Collections.Generic.ICollection<System.Threading.Tasks.Task<<T>>>tasksA list of tasks to race.
Type Parameters
NameDescription
TThe 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.

Declaration
public static Task CancellableDelay(int millisecondsDelay, CancellationToken cancellationToken)
Returns

System.Threading.Tasks.Task

Parameters
TypeName
System.Int32millisecondsDelay
System.Threading.CancellationTokencancellationToken