Dispatcher
A Unity package that helps run actions on the main thread, queuing actions from background threads and limiting execution time for smooth frame rates.

* This page contains affiliate links, meaning we may earn a small commission if you purchase something through them, at no extra cost. FREE
- Category:
- Tools › Utilities
- Developer:
- Vadim Andriyanov
- Price:
- FREE
- Rating:
- Favorites:
- 117
- Supported Unity Versions:
- 2021.3.31 or higher
- Current Version:
- 1.1
- Download Size:
- 15.92 KB
- Last Update:
- Mar 13, 2025
- Description:
- The Dispatcher class is designed to facilitate the execution of actions on the main thread in Unity. It works by queuing actions from background threads and executing them during the Update phase. This ensures that the frame rate remains smooth by limiting the time spent on each action.
To use the Dispatcher, follow these steps:
1. Add an Empty GameObject to your Scene.
2. Attach the Dispatcher component to the GameObject.
3. In your background thread function, use the Dispatcher.Current.BeginInvoke method to execute an action on the main thread.
Example code:
```csharp
Dispatcher.Current.BeginInvoke(() =>
{Output.text += param;
Output.text += Environment.NewLine;});
```
This will execute the action on the main thread.
For a complete demonstration, refer to the DispatcherTest.cs script. - Continue »