A collection of utilities and extensions to facilitate async programming.
More...
|
|
static AsyncOperationAwaiter | GetAwaiter (this AsyncOperation asyncOp) |
| | Extension method to easily get AsyncOperation awaiter in async/await context.
|
| |
|
static UnityWebRequestAwaiter | GetAwaiter (this UnityWebRequestAsyncOperation asyncOp) |
| | Extension method to easily get web request awaiter in async/await context.
|
| |
| static async Task | YieldUntil (Func< bool > condition) |
| | Shorthand to wait for a condition to be met checking on each frame.
|
| |
| static async Task | WaitUntil (Func< bool > condition, int pollingIntervalMs=100) |
| | Shorthand to wait for a condition to be met checking at a given polling interval.
|
| |
| static async Task< T > | WithTimeout< T > (this Task< T > task, string taskName, int timeoutMs=10000) |
| | Shorthand to await a task with a given timeout.
|
| |
|
static async Task | WithTimeout (this Task task, string taskName, int timeoutMs=10000) |
| |
|
static async Task< T > | WithRetry< T > (this Task< T > task, Func< T, bool > taskSuccessPredicate, string taskName, int numRetries=3, int retryIntervalMs=1000) |
| |
| static async Task | FireAndForget (this Task task, string taskName) |
| | Performs "fire and forget" (eg. for polling loops or other recurring work) for a task with proper exception logging to prevent errors from becoming unobservable.
|
| |
A collection of utilities and extensions to facilitate async programming.
◆ FireAndForget()
| static async Task FireAndForget |
( |
this Task | task, |
|
|
string | taskName ) |
|
inlinestatic |
Performs "fire and forget" (eg. for polling loops or other recurring work) for a task with proper exception logging to prevent errors from becoming unobservable.
- Parameters
-
| task | The task to fire and forget. |
| taskName | The name of the task to use in logs. |
◆ WaitUntil()
| static async Task WaitUntil |
( |
Func< bool > | condition, |
|
|
int | pollingIntervalMs = 100 ) |
|
inlinestatic |
Shorthand to wait for a condition to be met checking at a given polling interval.
- Parameters
-
| condition | A predicate that when true, this method should stop waiting. |
| pollingIntervalMs | The amount of time to wait between checking the predicate. |
- Returns
- An awaitable task that will complete once the condition is true.
◆ WithTimeout< T >()
| static async Task< T > WithTimeout< T > |
( |
this Task< T > | task, |
|
|
string | taskName, |
|
|
int | timeoutMs = 10000 ) |
|
inlinestatic |
Shorthand to await a task with a given timeout.
- Parameters
-
| task | The task to to await. |
| taskName | The name of the task to use in logs. |
| timeoutMs | The timeout period, after which the task is dropped. |
- Template Parameters
-
| T | The return type for the task. |
- Returns
- A task with the same return type but an exception is thrown if the timeout period finishes before the task.
- Exceptions
-
| TimeoutException | Thrown if the task times out. |
◆ YieldUntil()
| static async Task YieldUntil |
( |
Func< bool > | condition | ) |
|
|
inlinestatic |
Shorthand to wait for a condition to be met checking on each frame.
- Parameters
-
| condition | A predicate that when true, this method should stop waiting. |
- Returns
- An awaitable task that will complete once the condition is true.
The documentation for this class was generated from the following file:
- Runtime/Utilities/AsyncUtils.cs