public static void ExecuteBlocking(Action ac) { //check if we're on the main thread if (System.Threading.Thread.CurrentThread == uiThread) { ac(); return; } string uid = System.Guid.NewGuid().ToString(); busyWaitingFlags [uid] = false; realDispatcher.EnqueAction(() => { try { ac(); } catch (Exception e) { Debug.LogError(e); } finally { busyWaitingFlags[uid] = true; } }); //busy waiting while (busyWaitingFlags [uid] == false) { } //done }