logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Class UnityMainThreadDispatcher

    Unity-specific main-thread dispatcher. Captures the UnitySynchronizationContext and dispatches calls to it when the target type or method parameters involve Unity API types.

    Inheritance
    object
    UnityMainThreadDispatcher
    Implements
    IMainThreadDispatcher
    Inherited Members
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    object.GetType()
    Namespace: Serenity.UnityGlobal.Infrastructure.Services
    Assembly: Serenity.UnityGlobal.Infrastructure.dll
    Syntax
    public sealed class UnityMainThreadDispatcher : IMainThreadDispatcher

    Constructors

    UnityMainThreadDispatcher()

    Declaration
    public UnityMainThreadDispatcher()

    Properties

    IsAvailable

    Declaration
    public bool IsAvailable { get; }
    Property Value
    Type Description
    bool

    Methods

    CaptureContext()

    Captures the current synchronization context if it is the Unity context. Call this once from the main thread (e.g. during bootstrap).

    Declaration
    public void CaptureContext()

    InvokeOnMainThreadAsync(Func<Task>)

    Declaration
    public Task InvokeOnMainThreadAsync(Func<Task> action)
    Parameters
    Type Name Description
    Func<Task> action
    Returns
    Type Description
    Task

    RequiresMainThread(MethodInfo, Type)

    Declaration
    public bool RequiresMainThread(MethodInfo method, Type targetType)
    Parameters
    Type Name Description
    MethodInfo method
    Type targetType
    Returns
    Type Description
    bool

    Implements

    IMainThreadDispatcher
    In this article
    © 2026 Serenity. All Rights Reserved