Table of Contents

Class TaskUtil

Namespace
Hi.Common
Assembly
HiGeom.dll

Utility class for Task-related operations.

public static class TaskUtil
Inheritance
TaskUtil
Inherited Members

Methods

GenTask<TArg>(Action<TArg>, TArg)

Generates a new Task that will execute the specified function with the given argument.

public static Task GenTask<TArg>(Action<TArg> func, TArg arg)

Parameters

func Action<TArg>

The function to execute

arg TArg

The argument to pass to the function

Returns

Task

A new Task

Type Parameters

TArg

The type of the argument

GenTask<TArg>(Action<TArg>, TArg, CancellationToken)

Generates a new Task that will execute the specified function with the given argument and cancellation token.

public static Task GenTask<TArg>(Action<TArg> func, TArg arg, CancellationToken cancellationToken)

Parameters

func Action<TArg>

The function to execute

arg TArg

The argument to pass to the function

cancellationToken CancellationToken

The cancellation token

Returns

Task

A new Task

Type Parameters

TArg

The type of the argument

GenTask<TArg, TResult>(Func<TArg, TResult>, TArg)

Generates a new Task that will execute the specified function with the given argument and return a result.

public static Task<TResult> GenTask<TArg, TResult>(Func<TArg, TResult> func, TArg arg)

Parameters

func Func<TArg, TResult>

The function to execute

arg TArg

The argument to pass to the function

Returns

Task<TResult>

A new Task with a result

Type Parameters

TArg

The type of the argument

TResult

The type of the result

GenTask<TArg, TResult>(Func<TArg, TResult>, TArg, CancellationToken)

Generates a new Task that will execute the specified function with the given argument and cancellation token, and return a result.

public static Task<TResult> GenTask<TArg, TResult>(Func<TArg, TResult> func, TArg arg, CancellationToken cancellationToken)

Parameters

func Func<TArg, TResult>

The function to execute

arg TArg

The argument to pass to the function

cancellationToken CancellationToken

The cancellation token

Returns

Task<TResult>

A new Task with a result

Type Parameters

TArg

The type of the argument

TResult

The type of the result

GetTaskAwaiterResult(ValueTask)

Gets the result of a ValueTask by converting it to a Task and getting its awaiter result.

public static void GetTaskAwaiterResult(this ValueTask valueTask)

Parameters

valueTask ValueTask

The ValueTask

GetTaskAwaiterResult<TResult>(ValueTask<TResult>)

Gets the result of a ValueTask with a result by converting it to a Task and getting its awaiter result.

public static TResult GetTaskAwaiterResult<TResult>(this ValueTask<TResult> valueTask)

Parameters

valueTask ValueTask<TResult>

The ValueTask with a result

Returns

TResult

The result of the ValueTask

Type Parameters

TResult

The type of the result