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
obj
TThe object to be wrapped in a Task.
Returns
- Task<T>
A completed Task containing the object.
Type Parameters
T
The type of the object.
AsCoroutine(Task)
Converts the Task into an IEnumerator for Unity coroutine usage.
public static IEnumerator AsCoroutine(this Task task)
Parameters
task
TaskThe 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
task
TaskThe task to be forgotten.
onException
Action<Exception>The optional action to execute when an exception is caught. If provided, the exception will not be rethrown.