C# Class UnityTools.Threading.UnityDispatcher

The UnityDispatcher class allows you to execute code on the main Unity thread. This is useful for situations where you need code on a seperate thread (i.e. slow IO operations) to access things that can only be accessed on the main thread.
Inheritance: UnityEngine.MonoBehaviour, IInitialiseOnStartup, IDispatcher
Datei anzeigen Open project: NoxHarmonium/unity-tools Class Usage Examples

Public Methods

Method Description
Dispatch ( System.Action action ) : void

Dispatches the action asynchronously on the Unity main thread. The action will execute in the next frame update phase.

DispatchWait ( System.Action action ) : void

Dispatches the action asynchronously on the Unity main thread but blocks the current thread until the action is executed. The action will execute in the next frame update phase.

Initialise ( ) : void
PumpActionQueue ( ) : void

This method should be executed on the main dispatch thread to execute the queued dispatch actions.

Private Methods

Method Description
Awake ( ) : void
GetCurrentThreadId ( ) : int
Update ( ) : void

Method Details

Dispatch() public method

Dispatches the action asynchronously on the Unity main thread. The action will execute in the next frame update phase.
public Dispatch ( System.Action action ) : void
action System.Action The action to execute on the dispatch thread.
return void

DispatchWait() public method

Dispatches the action asynchronously on the Unity main thread but blocks the current thread until the action is executed. The action will execute in the next frame update phase.
public DispatchWait ( System.Action action ) : void
action System.Action The action to execute on the dispatch thread.
return void

Initialise() public method

public Initialise ( ) : void
return void

PumpActionQueue() public method

This method should be executed on the main dispatch thread to execute the queued dispatch actions.
public PumpActionQueue ( ) : void
return void