Just be curious, what if an action is (computationally) heavy, does other thread wait for a long time for the lock to be released?
// UnityMainThreadDispatcher.cs
public void Update() {
lock(_executionQueue) {
while (_executionQueue.Count > 0) {
_executionQueue.Dequeue().Invoke();
}
}
}