Class
- Namespace
- CoreFramework
Provides extension methods for the System.Threading.Tasks.Task class.
public static class TaskExtensions
- Inheritance
-
object
Methods
AsCompletedTask<T>(T)
Wraps the provided object into a completed Task.
public static Task<T> AsCompletedTask<T>(this T obj)
Parameters
objTThe object to be wrapped in a Task.
Returns
- Task<T>
A completed Task containing the object.
Type Parameters
TThe type of the object.
AsCoroutine(Task)
Converts the Task into an IEnumerator for Unity coroutine usage.
public static IEnumerator AsCoroutine(this Task task)
Parameters
taskTaskThe Task to convert.
Returns
- IEnumerator
An IEnumerator representation of the Task.
Forget(Task, Action<Exception>)
Marks a task to be forgotten, meaning any exceptions thrown by the task will be caught and handled.
public static void Forget(this Task task, Action<Exception> onException = null)
Parameters
taskTaskThe task to be forgotten.
onExceptionAction<Exception>The optional action to execute when an exception is caught. If provided, the exception will not be rethrown.