Class Coroutines
A class providing coroutine helpers.
Namespace: IPA.Utilities.Async
Assembly: IPA.Loader.dll
Syntax
public static class Coroutines : object
Methods
| Improve this Doc View SourceAsTask(IEnumerator)
Binds a
Declaration
public static Task AsTask(IEnumerator coroutine)
Parameters
Type | Name | Description |
---|---|---|
IEnumerator | coroutine | the coroutine to bind to a task |
Returns
Type | Description |
---|---|
Task | a |
Remarks
This may be called off of the Unity main thread. If it is, the coroutine start will be scheduled using the default UnityMainThreadTaskScheduler and will be run on the main thread as required by Unity.
Unity provides a handful of coroutine helpers that are not
WaitForTask(Task)
Stalls the coroutine until task
completes, faults, or is canceled.
Declaration
public static IEnumerator WaitForTask(Task task)
Parameters
Type | Name | Description |
---|---|---|
Task | task | the |
Returns
Type | Description |
---|---|
IEnumerator | a coroutine waiting for the given task |
WaitForTask(Task, Boolean)
Stalls the coroutine until task
completes, faults, or is canceled.
Declaration
public static IEnumerator WaitForTask(Task task, bool throwOnFault = false)
Parameters
Type | Name | Description |
---|---|---|
Task | task | the |
Boolean | throwOnFault | whether or not to throw if the task faulted |
Returns
Type | Description |
---|---|
IEnumerator | a coroutine waiting for the given task |