Show / Hide Table of Contents

Class TaskExtentions

Useful extension methods for System.Threading.Tasks.Task.

Inheritance
Object
TaskExtentions
Inherited Members
System.Object.ToString()
Object.Equals(Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
Object.MemberwiseClone()
Namespace: IRM
Assembly: IRM.dll
Syntax
public static class TaskExtentions

Methods

ContinueWithOnUIThread<T>(Task<T>, Action<T>)

Creates a continuation that executes asynchronously on the UI thread when the target System.Threading.Tasks.Task<TResult> completes.

Declaration
public static Task ContinueWithOnUIThread<T>(this Task<T> task, Action<T> action)
Parameters
System.Threading.Tasks.Task<T> task

The Task to continue the execution when finished.

System.Action<T> action

An action to run when the task completes. When run, the delegate will be passed the result of the completed task as an argument.

Returns
System.Threading.Tasks.Task

A new continuation System.Threading.Tasks.Task.

Type Parameters
T

The type of the tasks result.

ContinueWithOnUIThread<T, TResult>(Task<T>, Func<T, TResult>)

Creates a continuation that executes asynchronously on the UI thread when the target System.Threading.Tasks.Task<TResult> completes.

Declaration
public static Task<TResult> ContinueWithOnUIThread<T, TResult>(this Task<T> task, Func<T, TResult> func)
Parameters
System.Threading.Tasks.Task<T> task

The Task to continue the execution when finished.

System.Func<T, TResult> func

A function to run when the Task completes. When run, the delegate will be passed the result of the completed task as an argument.

Returns
System.Threading.Tasks.Task<TResult>

A new continuation System.Threading.Tasks.Task<TResult>.

Type Parameters
T

The type of the tasks result.

TResult

The type of the return value of the method that this delegate encapsulates.

RunSync(Func<Task>)

Runs the System.Func<TResult> synchronously on the default TaskScheduler.

Declaration
public static void RunSync(this Func<Task> func)
Parameters
System.Func<System.Threading.Tasks.Task> func

The System.Func<TResult> to run synchronously.

RunSync(Task)

Runs the System.Threading.Tasks.Task synchronously on the current TaskScheduler.

Declaration
public static Task RunSync(this Task task)
Parameters
System.Threading.Tasks.Task task

The Task to run synchronously.

Returns
System.Threading.Tasks.Task

RunSync<TResult>(Func<Task<TResult>>)

Runs the System.Func<TResult> synchronously on the default TaskScheduler.

Declaration
public static TResult RunSync<TResult>(this Func<Task<TResult>> func)
Parameters
System.Func<System.Threading.Tasks.Task<TResult>> func

The System.Func<TResult> to run synchronously.

Returns
TResult

Type Parameters
TResult

RunSync<T>(Task<T>)

Runs the System.Threading.Tasks.Task synchronously on the current TaskScheduler.

Declaration
public static Task<T> RunSync<T>(this Task<T> task)
Parameters
System.Threading.Tasks.Task<T> task

The Task to run synchronously.

Returns
System.Threading.Tasks.Task<T>

Type Parameters
T

Back to top Generated by DocFX