Class Async
Class Async.
Namespace: Unity.Industrial.Forma.Core.Utils
Syntax
[MovedFrom(true, "UnityEngine.Industrial.Configuring.Utils", "Unity.Industrial.Configurator", null)]
public static class Async
Methods
CheckExceptions()
This will report whatever exception from the last-run coroutine (using RunThrowingIterator(enumerator)). The error message will be from the correct exception, but the user will need to find the inner exception message to see where the error originated from. Not ideal but better then nothing.
Declaration
public static void CheckExceptions()
Exceptions
| Type | Condition |
|---|---|
| Exception |
Run(Action)
Executes an action with try/catch and exception logging
Declaration
public static void Run(Action action)
Parameters
| Type | Name | Description |
|---|---|---|
| Action | action |
Run(IEnumerator)
Keeps last error that you can then check for
Declaration
public static IEnumerator Run(IEnumerator enumerator)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerator | enumerator | The enumerator. |
Returns
| Type | Description |
|---|---|
| IEnumerator | IEnumerator. |
Run(IEnumerator, Action<Exception>)
Run an iterator function that might throw an exception. Call the callback with the exception if it does or null if it finishes without throwing an exception.
Declaration
public static IEnumerator Run(IEnumerator enumerator, Action<Exception> done)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerator | enumerator | Iterator function to run |
| Action<Exception> | done | Callback to call when the iterator has thrown an exception or finished. The thrown exception or null is passed as the parameter. |
Returns
| Type | Description |
|---|---|
| IEnumerator | An enumerator that runs the given enumerator |
RunTask(Task)
Awaits a task with try/catch and exception logging. Rethrows the exception
Declaration
public static async Task RunTask(Task task)
Parameters
| Type | Name | Description |
|---|---|---|
| Task | task |
Returns
| Type | Description |
|---|---|
| Task | Task |
RunTaskSafe(Task)
Awaits a task with try/catch all exceptions and logs exception
Declaration
public static async Task RunTaskSafe(Task task)
Parameters
| Type | Name | Description |
|---|---|---|
| Task | task |
Returns
| Type | Description |
|---|---|
| Task | Task |
StartThrowingCoroutine(MonoBehaviour, IEnumerator, Action<Exception>)
Start a coroutine that might throw an exception. Call the callback with the exception if it does or null if it finishes without throwing an exception.
Declaration
public static Coroutine StartThrowingCoroutine(this MonoBehaviour monoBehaviour, IEnumerator enumerator, Action<Exception> done)
Parameters
| Type | Name | Description |
|---|---|---|
| MonoBehaviour | monoBehaviour | MonoBehaviour to start the coroutine on |
| IEnumerator | enumerator | Iterator function to run as the coroutine |
| Action<Exception> | done | Callback to call when the coroutine has thrown an exception or finished. The thrown exception or null is passed as the parameter. |
Returns
| Type | Description |
|---|---|
| Coroutine | The started coroutine |
Wait(Func<Boolean>, Int32)
Waits the specified predicate.
Declaration
public static IEnumerator Wait(Func<bool> predicate, int maxCount = 100)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<Boolean> | predicate | The predicate. |
| Int32 | maxCount | The maximum count. |
Returns
| Type | Description |
|---|---|
| IEnumerator | IEnumerator. |
Yield(Int32)
Yields the specified count.
Declaration
public static IEnumerator Yield(int count = 1)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | count | The count. |
Returns
| Type | Description |
|---|---|
| IEnumerator | IEnumerator. |