Task Factory is used to create new Tasks and Schedule long running Tasks.
More...
|
| static Task | ContinueWhenAll (Task[] precedingTasks, Func< CancellationToken, Task > action, CancellationToken cancellationToken) |
| | Run a continuation Task after all other Tasks have completed.
|
| static async Task | Delay (int delay, CancellationToken token=default) |
| | Custom Task Delay method as Task.Delay is not supported by WebGL Builds.
|
| static Task | Run (Func< CancellationToken, Task > action, CancellationToken cancellationToken, TaskCreationOptions options=TaskCreationOptions.None) |
| | Run an Action asynchronously.
|
| static Task | Service (Action recurringAction, CancellationToken cancellationToken, int interval, string serviceName=null) |
| | Starts a service task that will invoke a recurring action at specified intervals.
|
| static Task | Service (Func< Task< bool > > recurringAction, CancellationToken cancellationToken, int interval, string serviceName=null) |
| | Start a Service Task that will invoke a Recurring Action every each interval in millis.
|
|
static void | Setup () |
| | Setup a new TaskFactory tailored to work with Unity.
|
Task Factory is used to create new Tasks and Schedule long running Tasks.
◆ ContinueWhenAll()
| Task ContinueWhenAll |
( |
Task[] | precedingTasks, |
|
|
Func< CancellationToken, Task > | action, |
|
|
CancellationToken | cancellationToken ) |
|
static |
Run a continuation Task after all other Tasks have completed.
- Parameters
-
| precedingTasks | List of pending tasks to wait |
| action | Action to run after the Tasks |
| cancellationToken | ellationToken used to stop the Action |
- Returns
- Async Task based on the Action
◆ Delay()
| async Task Delay |
( |
int | delay, |
|
|
CancellationToken | token = default ) |
|
static |
Custom Task Delay method as Task.Delay is not supported by WebGL Builds.
- Parameters
-
| delay | Delay in milliseconds to wait |
| token | Cancellation Token used to stop the Delay |
- Returns
- Awaitable Task
◆ Run()
| Task Run |
( |
Func< CancellationToken, Task > | action, |
|
|
CancellationToken | cancellationToken, |
|
|
TaskCreationOptions | options = TaskCreationOptions::None ) |
|
static |
Run an Action asynchronously.
- Parameters
-
| action | Action to be invoked |
| cancellationToken | CancellationToken used to stop the Action |
| options | Extra Task Creation options |
- Returns
- Async Task based on the Action
◆ Service() [1/2]
| Task Service |
( |
Action | recurringAction, |
|
|
CancellationToken | cancellationToken, |
|
|
int | interval, |
|
|
string | serviceName = null ) |
|
static |
Starts a service task that will invoke a recurring action at specified intervals.
- Parameters
-
| recurringAction | The action to be invoked at each interval. |
| cancellationToken | The cancellation token used to stop the service. |
| interval | The interval in milliseconds between each invocation of the action. |
| serviceName | An optional custom name for the service. |
- Returns
- A task representing the service.
◆ Service() [2/2]
| Task Service |
( |
Func< Task< bool > > | recurringAction, |
|
|
CancellationToken | cancellationToken, |
|
|
int | interval, |
|
|
string | serviceName = null ) |
|
static |
Start a Service Task that will invoke a Recurring Action every each interval in millis.
- Parameters
-
| recurringAction | Action invoked every interval. It can return false to stop the service |
| cancellationToken | CancellationToken used to stop the service |
| interval | Interval between action invoke |
| serviceName | Custom id name for the Service |
- Returns
- Service Task