Class UnityMainThreadTaskScheduler
A task scheduler that runs tasks on the Unity main thread via coroutines.
Implements
Namespace: IPA.Utilities.Async
Assembly: IPA.Loader.dll
Syntax
public class UnityMainThreadTaskScheduler : TaskScheduler
Properties
| Improve this Doc View SourceCancelling
Gets whether or not this scheduler is in the process of shutting down.
Declaration
public bool Cancelling { get; }
Property Value
Type | Description |
---|---|
Boolean | true if the scheduler is shutting down, false otherwise |
Default
Gets the default main thread scheduler that is managed by BSIPA.
Declaration
public static TaskScheduler Default { get; }
Property Value
Type | Description |
---|---|
TaskScheduler | a scheduler that is managed by BSIPA |
Factory
Gets a factory for creating tasks on Default.
Declaration
public static TaskFactory Factory { get; }
Property Value
Type | Description |
---|---|
TaskFactory | a factory for creating tasks on the default scheduler |
IsRunning
Gets whether or not this scheduler is currently executing tasks.
Declaration
public bool IsRunning { get; }
Property Value
Type | Description |
---|---|
Boolean | true if the scheduler is running, false otherwise |
YieldAfterTasks
Gets or sets the number of tasks to execute before yielding back to Unity.
Declaration
public int YieldAfterTasks { get; set; }
Property Value
Type | Description |
---|---|
Int32 | the number of tasks to execute per resume |
YieldAfterTime
Gets or sets the amount of time to execute tasks for before yielding back to Unity. Default is 0.5ms.
Declaration
public TimeSpan YieldAfterTime { get; set; }
Property Value
Type | Description |
---|---|
TimeSpan | the amount of time to execute tasks for before yielding back to Unity |
Methods
| Improve this Doc View SourceCancel()
Cancels the scheduler. If the scheduler is currently executing tasks, that batch will finish first. All remaining tasks will be left in the queue.
Declaration
public void Cancel()
Coroutine()
When used as a Unity coroutine, runs the scheduler. Otherwise, this is an invalid call.
Declaration
public IEnumerator Coroutine()
Returns
Type | Description |
---|---|
IEnumerator | a Unity coroutine |
Remarks
Do not ever call
If you need to stop this coroutine, first call Cancel(), then wait for it to exit on its own.
Dispose()
Disposes this object. This puts the object into an unusable state.
Declaration
public void Dispose()
Dispose(Boolean)
Disposes this object.
Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
Boolean | disposing | whether or not to dispose managed objects |
GetScheduledTasks()
Throws a
Declaration
protected override IEnumerable<Task> GetScheduledTasks()
Returns
Type | Description |
---|---|
IEnumerable<Task> | nothing |
QueueTask(Task)
Queues a given
Declaration
protected override void QueueTask(Task task)
Parameters
Type | Name | Description |
---|---|---|
Task | task | the |
TryExecuteTaskInline(Task, Boolean)
Runs the task inline if the current thread is the Unity main thread.
Declaration
protected override bool TryExecuteTaskInline(Task task, bool taskWasPreviouslyQueued)
Parameters
Type | Name | Description |
---|---|---|
Task | task | the task to attempt to execute |
Boolean | taskWasPreviouslyQueued | whether the task was previously queued to this scheduler |
Returns
Type | Description |
---|---|
Boolean | false if the task could not be run, true if it was |