A thread-safe class which holds a queue with actions to execute on the next Update() method. It can be used to make calls to the main thread for things such as UI Manipulation in Unity. It was developed for use in combination with the Firebase Unity plugin, which uses separate threads for event handling.
More...
|
void | Update () |
|
void | Enqueue (IEnumerator action) |
| Locks the queue and adds the IEnumerator to the queue.
|
|
void | Enqueue (Action action) |
| Locks the queue and adds the Action to the queue.
|
|
Task | EnqueueAsync (Action action) |
| Locks the queue and adds the Action to the queue, returning a Task which is completed when the action completes.
|
|
A thread-safe class which holds a queue with actions to execute on the next Update() method. It can be used to make calls to the main thread for things such as UI Manipulation in Unity. It was developed for use in combination with the Firebase Unity plugin, which uses separate threads for event handling.
Author: Pim de Witte (pimdewitte.com) and contributors, https://github.com/PimDeWitte/UnityMainThreadDispatcher
◆ ActionWrapper()
IEnumerator UnityMainThreadDispatcher.ActionWrapper |
( |
Action | a | ) |
|
|
private |
◆ Awake()
void UnityMainThreadDispatcher.Awake |
( |
| ) |
|
|
private |
◆ Enqueue() [1/2]
void UnityMainThreadDispatcher.Enqueue |
( |
Action | action | ) |
|
Locks the queue and adds the Action to the queue.
- Parameters
-
action | function that will be executed from the main thread. |
◆ Enqueue() [2/2]
void UnityMainThreadDispatcher.Enqueue |
( |
IEnumerator | action | ) |
|
Locks the queue and adds the IEnumerator to the queue.
- Parameters
-
action | IEnumerator function that will be executed from the main thread. |
◆ EnqueueAsync()
Task UnityMainThreadDispatcher.EnqueueAsync |
( |
Action | action | ) |
|
Locks the queue and adds the Action to the queue, returning a Task which is completed when the action completes.
- Parameters
-
action | function that will be executed from the main thread. |
- Returns
- A Task that can be awaited until the action completes
◆ Exists()
static bool UnityMainThreadDispatcher.Exists |
( |
| ) |
|
|
static |
◆ Instance()
◆ OnDestroy()
void UnityMainThreadDispatcher.OnDestroy |
( |
| ) |
|
|
private |
◆ Update()
void UnityMainThreadDispatcher.Update |
( |
| ) |
|
◆ _executionQueue
readonly Queue<Action> UnityMainThreadDispatcher._executionQueue = new Queue<Action>() |
|
staticprivate |
◆ _instance
The documentation for this class was generated from the following file: