docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Interface IUnityThreadUtils

    This component is an utility to simplify working with the Unity thread.

    Namespace: Unity.Services.Core.Threading.Internal
    Assembly: Unity.Services.Core.Internal.dll
    Syntax
    public interface IUnityThreadUtils : IServiceComponent

    Properties

    IsRunningOnUnityThread

    Check if the calling thread is the Unity thread.

    Declaration
    bool IsRunningOnUnityThread { get; }
    Property Value
    Type Description
    bool

    Methods

    PostAsync(Action)

    Create a task out of the given action that will be invoked on the Unity thread.

    Declaration
    Task PostAsync(Action action)
    Parameters
    Type Name Description
    Action action

    The action to invoke on the Unity thread.

    Returns
    Type Description
    Task

    Return the created task.

    PostAsync(Action<object>, object)

    Create a task out of the given action that will be invoked on the Unity thread.

    Declaration
    Task PostAsync(Action<object> action, object state)
    Parameters
    Type Name Description
    Action<object> action

    The action to invoke on the Unity thread. state will be passed as its argument.

    object state

    The captured state to pass to action when invoking it.

    Returns
    Type Description
    Task

    Return the created task.

    PostAsync<T>(Func<object, T>, object)

    Create a task out of the given action that will be invoked on the Unity thread.

    Declaration
    Task<T> PostAsync<T>(Func<object, T> action, object state)
    Parameters
    Type Name Description
    Func<object, T> action

    The action to invoke on the Unity thread. state will be passed as its argument.

    object state

    The captured state to pass to action when invoking it.

    Returns
    Type Description
    Task<T>

    Return the created task.

    Type Parameters
    Name Description
    T

    The type of the return of the invoked action. Can be any type.

    PostAsync<T>(Func<T>)

    Create a task out of the given action that will be invoked on the Unity thread.

    Declaration
    Task<T> PostAsync<T>(Func<T> action)
    Parameters
    Type Name Description
    Func<T> action

    The action to invoke on the Unity thread.

    Returns
    Type Description
    Task<T>

    Return the created task.

    Type Parameters
    Name Description
    T

    The type of the return of the invoked action. Can be any type.

    Send(Action)

    Execute the given action on the Unity thread. Wait for the execution to finish before resuming this thread.

    Declaration
    void Send(Action action)
    Parameters
    Type Name Description
    Action action

    The action to invoke on the Unity thread.

    Send(Action<object>, object)

    Execute the given action on the Unity thread. Wait for the execution to finish before resuming this thread.

    Declaration
    void Send(Action<object> action, object state)
    Parameters
    Type Name Description
    Action<object> action

    The action to invoke on the Unity thread. state will be passed as its argument.

    object state

    The captured state to pass to action when invoking it.

    Send<T>(Func<object, T>, object)

    Execute the given action on the Unity thread. Wait for the execution to finish before resuming this thread.

    Declaration
    T Send<T>(Func<object, T> action, object state)
    Parameters
    Type Name Description
    Func<object, T> action

    The action to invoke on the Unity thread. state will be passed as its argument.

    object state

    The captured state to pass to action when invoking it.

    Returns
    Type Description
    T

    Return what the action returned.

    Type Parameters
    Name Description
    T

    The type of the return of the invoked action. Can be any type.

    Send<T>(Func<T>)

    Execute the given action on the Unity thread. Wait for the execution to finish before resuming this thread.

    Declaration
    T Send<T>(Func<T> action)
    Parameters
    Type Name Description
    Func<T> action

    The action to invoke on the Unity thread.

    Returns
    Type Description
    T

    Return what the action returned.

    Type Parameters
    Name Description
    T

    The type of the return of the invoked action. Can be any type.

    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)