Photon Fusion 2.0.3

Static Public Member Functions | List of all members
TaskManager Class Reference

Task Factory is used to create new Tasks and Schedule long running Tasks More...

Static Public Member Functions

static Task ContinueWhenAll (Task[] precedingTasks, Func< CancellationToken, Task > action, CancellationToken cancellationToken)
 Run a continuation Task after all other Tasks have completed More...
 
static async Task Delay (int delay, CancellationToken token=default)
 Custom Task Delay method as Task.Delay is not supported by WebGL Builds More...
 
static Task Run (Func< CancellationToken, Task > action, CancellationToken cancellationToken, TaskCreationOptions options=TaskCreationOptions.None)
 Run an Action asynchronously More...
 
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. More...
 
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 More...
 
static void Setup ()
 Setup a new TaskFactory tailored to work with Unity More...
 

Detailed Description

Task Factory is used to create new Tasks and Schedule long running Tasks

Member Function Documentation

◆ ContinueWhenAll()

static Task ContinueWhenAll ( Task[]  precedingTasks,
Func< CancellationToken, Task >  action,
CancellationToken  cancellationToken 
)
static

Run a continuation Task after all other Tasks have completed

Parameters
precedingTasksList of pending tasks to wait
actionAction to run after the Tasks
cancellationTokenellationToken used to stop the Action
Returns
Async Task based on the Action

◆ Delay()

static async Task Delay ( int  delay,
CancellationToken  token = default 
)
static

Custom Task Delay method as Task.Delay is not supported by WebGL Builds

Parameters
delayDelay in milliseconds to wait
tokenCancellation Token used to stop the Delay
Returns
Awaitable Task

◆ Run()

static Task Run ( Func< CancellationToken, Task >  action,
CancellationToken  cancellationToken,
TaskCreationOptions  options = TaskCreationOptions.None 
)
static

Run an Action asynchronously

Parameters
actionAction to be invoked
cancellationTokenCancellationToken used to stop the Action
optionsExtra Task Creation options
Returns
Async Task based on the Action

◆ Service() [1/2]

static 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
recurringActionThe action to be invoked at each interval.
cancellationTokenThe cancellation token used to stop the service.
intervalThe interval in milliseconds between each invocation of the action.
serviceNameAn optional custom name for the service.
Returns
A task representing the service.

◆ Service() [2/2]

static 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
recurringActionAction invoked every interval. It can return false to stop the service
cancellationTokenCancellationToken used to stop the service
intervalInterval between action invoke
serviceNameCustom id name for the Service
Returns
Service Task

◆ Setup()

static void Setup ( )
static

Setup a new TaskFactory tailored to work with Unity