using System; using System.Collections.Generic; using Unity.UIWidgets.foundation; using UnityEngine; namespace Unity.UIWidgets.async { public class MicrotaskQueue { readonly Queue _queue = new Queue(); public void scheduleMicrotask(Action action) { this._queue.Enqueue(action); } public void flushMicrotasks() { while (this._queue.isNotEmpty()) { var action = this._queue.Dequeue(); try { action(); } catch (Exception ex) { Debug.LogError("Error to execute microtask: " + ex); } } } } }