Show / Hide Table of Contents

    Class UnityMainThreadTaskScheduler

    A task scheduler that runs tasks on the Unity main thread via coroutines.

    Inheritance
    Object
    TaskScheduler
    UnityMainThreadTaskScheduler
    Implements
    IDisposable
    Inherited Members
    TaskScheduler.TryDequeue(Task)
    TaskScheduler.FromCurrentSynchronizationContext()
    TaskScheduler.TryExecuteTask(Task)
    TaskScheduler.MaximumConcurrencyLevel
    TaskScheduler.Current
    TaskScheduler.Id
    TaskScheduler.UnobservedTaskException
    Object.ToString()
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Namespace: IPA.Utilities.Async
    Assembly: IPA.Loader.dll
    Syntax
    public class UnityMainThreadTaskScheduler : TaskScheduler, IDisposable

    Properties

    | Improve this Doc View Source

    Cancelling

    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

    | Improve this Doc View Source

    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

    | Improve this Doc View Source

    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

    | Improve this Doc View Source

    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

    | Improve this Doc View Source

    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

    | Improve this Doc View Source

    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 Source

    Cancel()

    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()
    Exceptions
    Type Condition
    ObjectDisposedException

    if this scheduler is disposed

    InvalidOperationException

    if the scheduler is not running

    | Improve this Doc View Source

    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 UnityEngine.MonoBehaviour.StopCoroutine(System.Collections.IEnumerator) on this coroutine, nor UnityEngine.MonoBehaviour.StopAllCoroutines() on the behaviour hosting this coroutine. This has no way to detect this, and this object will become invalid.

    If you need to stop this coroutine, first call Cancel(), then wait for it to exit on its own.

    Exceptions
    Type Condition
    ObjectDisposedException

    if this scheduler is disposed

    InvalidOperationException

    if the scheduler is already running

    | Improve this Doc View Source

    Dispose()

    Disposes this object. This puts the object into an unusable state.

    Declaration
    public void Dispose()
    | Improve this Doc View Source

    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

    | Improve this Doc View Source

    GetScheduledTasks()

    Throws a NotSupportedException.

    Declaration
    protected override IEnumerable<Task> GetScheduledTasks()
    Returns
    Type Description
    IEnumerable<Task>

    nothing

    Overrides
    TaskScheduler.GetScheduledTasks()
    Exceptions
    Type Condition
    NotSupportedException

    Always.

    | Improve this Doc View Source

    QueueTask(Task)

    Queues a given Task to this scheduler. The Task must> be scheduled for this TaskScheduler by the runtime.

    Declaration
    protected override void QueueTask(Task task)
    Parameters
    Type Name Description
    Task task

    the Task to queue

    Overrides
    TaskScheduler.QueueTask(Task)
    Exceptions
    Type Condition
    ObjectDisposedException

    Thrown if this object has already been disposed.

    | Improve this Doc View Source

    TryExecuteTaskInline(Task, Boolean)

    Rejects any attempts to execute a task inline.

    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
    Overrides
    TaskScheduler.TryExecuteTaskInline(Task, Boolean)
    Remarks

    This task scheduler always runs its tasks on the thread that it manages, therefore it doesn't make sense to run it inline.

    Exceptions
    Type Condition
    ObjectDisposedException

    Thrown if this object has already been disposed.

    Implements

    System.IDisposable

    Extension Methods

    ReflectionUtil.SetField<T, U>(T, String, U)
    ReflectionUtil.GetField<U, T>(T, String)
    ReflectionUtil.SetProperty<T, U>(T, String, U)
    ReflectionUtil.GetProperty<U, T>(T, String)
    ReflectionUtil.InvokeMethod<U, T>(T, String, Object[])
    • Improve this Doc
    • View Source
    Back to top Generated by DocFX