Skip to main content

Class TaskExtensions

Extension methods to make working with System.Threading.Tasks.Task easier.

Assembly: Dalamud.dll
View Source
Declaration
public static class TaskExtensions

Methods

WaitSafely(Task)

Safe alternative to Task.Wait which ensures the calling thread is not a thread pool thread.

View Source
Declaration
public static void WaitSafely(this Task task)
Parameters
TypeNameDescription
System.Threading.Tasks.TasktaskThe task to be awaited.

GetResultSafely<T>(Task<T>)

Safe alternative to Task.Result which ensures the calling thread is not a thread pool thread.

View Source
Declaration
public static T GetResultSafely<T>(this Task<T> task)
Returns

<T>: The result.

Parameters
TypeNameDescription
System.Threading.Tasks.Task<<T>>taskThe target task.
Type Parameters
NameDescription
TThe type of the result.

SuppressException(Task)

Creates a new System.Threading.Tasks.Task that resolves when <code class="paramref">task</code> completes, ignoring exceptions thrown from the task, if any.

View Source
Declaration
public static Task SuppressException(this Task task)
Returns

System.Threading.Tasks.Task: A System.Threading.Tasks.Task that completes successfully when <code class="paramref">task</code> completes in any state.

Parameters
TypeNameDescription
System.Threading.Tasks.TasktaskTask to await and ignore exceptions on failure.