Class TaskUtil
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
funcAction<TArg>The function to execute
argTArgThe argument to pass to the function
Returns
- Task
A new Task
Type Parameters
TArgThe 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
funcAction<TArg>The function to execute
argTArgThe argument to pass to the function
cancellationTokenCancellationTokenThe cancellation token
Returns
- Task
A new Task
Type Parameters
TArgThe 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
funcFunc<TArg, TResult>The function to execute
argTArgThe argument to pass to the function
Returns
- Task<TResult>
A new Task with a result
Type Parameters
TArgThe type of the argument
TResultThe 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
funcFunc<TArg, TResult>The function to execute
argTArgThe argument to pass to the function
cancellationTokenCancellationTokenThe cancellation token
Returns
- Task<TResult>
A new Task with a result
Type Parameters
TArgThe type of the argument
TResultThe 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
valueTaskValueTaskThe 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
valueTaskValueTask<TResult>The ValueTask with a result
Returns
- TResult
The result of the ValueTask
Type Parameters
TResultThe type of the result