Class TaskScheduler
Provides the means to schedule tasks on a background thread or the main thread. Also allows for creation of co-routines from classes that do not inherit from MonoBehaviour.
This is thread safe, through it must be constructed on the main thread.
Inherited Members
Object.FindObjectsByType<T>(FindObjectsSortMode)
Object.FindObjectsByType<T>(FindObjectsInactive, FindObjectsSortMode)
Object.FindFirstObjectByType<T>()
Object.FindAnyObjectByType<T>()
Object.FindFirstObjectByType<T>(FindObjectsInactive)
Object.FindAnyObjectByType<T>(FindObjectsInactive)
Namespace: Unity.Services.Lobbies.Scheduler
Assembly: Unity.Services.Lobbies.dll
Syntax
public abstract class TaskScheduler : MonoBehaviour
Methods
IsMainThread()
Determines whether the current thread is the main thread.
Declaration
public abstract bool IsMainThread()
Returns
Type | Description |
---|---|
bool | Whether or not this thread is the main thread. |
ScheduleBackgroundTask(Action)
Schedules a new task on a background thread.
Declaration
public abstract void ScheduleBackgroundTask(Action task)
Parameters
Type | Name | Description |
---|---|---|
Action | task | The task that should be executed on a background thread. |
ScheduleMainThreadTask(Action)
Schedules a new task on the main thread. The task will be executed during the next update.
Declaration
public abstract void ScheduleMainThreadTask(Action task)
Parameters
Type | Name | Description |
---|---|---|
Action | task | The task that should be executed on the main thread. |
ScheduleOrExecuteOnMain(Action)
Executes immediately if on main thread else queue on main thread for next update.
Declaration
public void ScheduleOrExecuteOnMain(Action action)
Parameters
Type | Name | Description |
---|---|---|
Action | action | The task that should be executed on the main thread. |