/// <summary> /// Send an Action Delegate to be run on the main thread. See EditorDispatchActions for some common usecases. /// </summary> /// <param name="task">An action delegate to run on the main thread</param> /// <returns>An AsyncDispatch that can be used to track if the dispatch has completed.</returns> public static AsyncDispatch Dispatch(Action task) { lock (dispatchQueue) { AsyncDispatch dispatch = new AsyncDispatch(); // enqueue a new task that runs the supplied task and completes the dispatcher dispatchQueue.Enqueue(() => { task(); dispatch.FinishedDispatch(); }); return(dispatch); } }
private static IEnumerator DispatchCorotine(IEnumerator dispatched, AsyncDispatch tracker) { yield return(dispatched); tracker.FinishedDispatch(); }