Show / Hide Table of Contents

    Class Dispatcher

    A helper class to Dispatch actions to the GameThread

    Inheritance
    Object
    Dispatcher
    Inherited Members
    Object.ToString()
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Namespace: Microsoft.MixedReality.SpectatorView
    Assembly: cs.temp.dll.dll
    Syntax
    public static class Dispatcher

    Properties

    CurrentThreadId

    Returns the Id of the current managed thread.

    Declaration
    public static int CurrentThreadId { get; }
    Property Value
    Type Description
    Int32

    IsGameThread

    Returns whether or not the calling thread is in fact a game thread.

    Declaration
    public static bool IsGameThread { get; }
    Property Value
    Type Description
    Boolean

    Methods

    Initialize(Int32, TaskScheduler)

    Declaration
    public static void Initialize(int mainThreadId, TaskScheduler mainThreadScheduler)
    Parameters
    Type Name Description
    Int32 mainThreadId
    TaskScheduler mainThreadScheduler

    ScheduleAsync(Action, CancellationToken, Boolean)

    Schedules an action to be executed on the GameThread task scheduler.

    Declaration
    public static Task ScheduleAsync(Action action, CancellationToken cancellationToken, bool runImmediateIfOnGameThread = false)
    Parameters
    Type Name Description
    Action action

    The action to execute.

    CancellationToken cancellationToken

    CancellationToken to cancel the operation.

    Boolean runImmediateIfOnGameThread

    If true, will check if current thread is the game thread and execute the dispatched operation immediately.

    Returns
    Type Description
    Task

    The Task representing the asynchronous operation.

    ScheduleAsync(Func<Task>, CancellationToken, Boolean)

    Schedules an asyncrhonous action to be executed on the GameThread task scheduler.

    Declaration
    public static Task ScheduleAsync(Func<Task> asyncAction, CancellationToken cancellationToken, bool runImmediateIfOnGameThread = false)
    Parameters
    Type Name Description
    Func<Task> asyncAction

    The asyncrhonous action to execute.

    CancellationToken cancellationToken

    CancellationToken to cancel the operation.

    Boolean runImmediateIfOnGameThread

    If true, will check if current thread is the game thread and execute the dispatched operation immediately.

    Returns
    Type Description
    Task

    The Task representing the unwrapped asynchronous operation.

    ScheduleAsync<TResult>(Func<TResult>, CancellationToken, Boolean)

    Schedules a function to be executed on the GameThread task scheduler.

    Declaration
    public static Task<TResult> ScheduleAsync<TResult>(Func<TResult> func, CancellationToken cancellationToken, bool runImmediateIfOnGameThread = false)
    Parameters
    Type Name Description
    Func<TResult> func

    The function to execute.

    CancellationToken cancellationToken

    CancellationToken to cancel the operation.

    Boolean runImmediateIfOnGameThread

    If true, will check if current thread is the game thread and execute the dispatched operation immediately.

    Returns
    Type Description
    Task<TResult>

    The Task representing the asynchronous operation.

    Type Parameters
    Name Description
    TResult

    The generic type of the return parameter.

    ScheduleAsync<TResult>(Func<Task<TResult>>, CancellationToken, Boolean)

    Schedules an asycnrhonous function to be executed on the GameThread task scheduler.

    Declaration
    public static Task<TResult> ScheduleAsync<TResult>(Func<Task<TResult>> asyncFunc, CancellationToken cancellationToken, bool runImmediateIfOnGameThread = false)
    Parameters
    Type Name Description
    Func<Task<TResult>> asyncFunc
    CancellationToken cancellationToken

    CancellationToken to cancel the operation.

    Boolean runImmediateIfOnGameThread

    If true, will check if current thread is the game thread and execute the dispatched operation immediately.

    Returns
    Type Description
    Task<TResult>

    The Task representing the unwrapped asynchronous operation.

    Type Parameters
    Name Description
    TResult

    The generic type of the return parameter.

    ThrowIfNotGameThread()

    A helper that throws if the current thread is not a game thread.

    Declaration
    public static void ThrowIfNotGameThread()

    Unintialize()

    Declaration
    public static void Unintialize()

    WaitForNextFrameAsync()

    A helper to wait for next frame.

    Declaration
    public static Task WaitForNextFrameAsync()
    Returns
    Type Description
    Task

    The Task representing the asynchronous operation.

    WhenAsync(Func<Boolean>, CancellationToken)

    Conducts a polling wait on the game thread until a predicate is satisfied.

    Declaration
    public static Task WhenAsync(Func<bool> predicate, CancellationToken cancellationToken)
    Parameters
    Type Name Description
    Func<Boolean> predicate

    The condition to wait for.

    CancellationToken cancellationToken

    CancellationToken to cancel the operation.

    Returns
    Type Description
    Task

    The Task representing the asynchronous operation.

    WhenNotNullAsync<T>(Func<T>, CancellationToken)

    Conducts a polling wait on the game thread until an result returend by an evaluator is no longer null.

    Declaration
    public static Task<T> WhenNotNullAsync<T>(Func<T> evaluator, CancellationToken cancellationToken)
        where T : class
    Parameters
    Type Name Description
    Func<T> evaluator

    The function that returns the result to check for null.

    CancellationToken cancellationToken

    CancellationToken to cancel the operation.

    Returns
    Type Description
    Task<T>

    The Task representing the asynchronous operation.

    Type Parameters
    Name Description
    T
    In This Article
    • Properties
      • CurrentThreadId
      • IsGameThread
    • Methods
      • Initialize(Int32, TaskScheduler)
      • ScheduleAsync(Action, CancellationToken, Boolean)
      • ScheduleAsync(Func<Task>, CancellationToken, Boolean)
      • ScheduleAsync<TResult>(Func<TResult>, CancellationToken, Boolean)
      • ScheduleAsync<TResult>(Func<Task<TResult>>, CancellationToken, Boolean)
      • ThrowIfNotGameThread()
      • Unintialize()
      • WaitForNextFrameAsync()
      • WhenAsync(Func<Boolean>, CancellationToken)
      • WhenNotNullAsync<T>(Func<T>, CancellationToken)
    Back to top Generated by DocFX