public static void RunDelayAction() { if (_delayed.Count >= 1) { List <DelayedQueueItem> list = _delayed; lock (list) { int num2; _currentDelayed.Clear(); for (int i = 0; i < _delayed.Count; i = num2 + 1) { DelayedQueueItem item = _delayed[i]; if (item.time <= Time.time) { _currentDelayed.Add(item); } num2 = i; } for (int j = 0; j < _currentDelayed.Count; j = num2 + 1) { DelayedQueueItem item2 = _currentDelayed[j]; _delayed.Remove(item2); num2 = j; } for (int k = 0; k < _currentDelayed.Count; k = num2 + 1) { DelayedQueueItem item3 = _currentDelayed[k]; item3.action(); num2 = k; } } } }
public static void QueueOnMainThread(Action action, float time) { if (time != 0f) { List <DelayedQueueItem> list = _delayed; lock (list) { DelayedQueueItem item = new DelayedQueueItem { time = Time.time + time, action = action }; _delayed.Add(item); } } else { _actions.Enqueue(action); } }
public static void RunDelayAction() { bool flag = MainThreadDispatcher._delayed.Count < 1; if (!flag) { List <DelayedQueueItem> delayed = MainThreadDispatcher._delayed; Monitor.Enter(delayed); try { MainThreadDispatcher._currentDelayed.Clear(); int num; for (int i = 0; i < MainThreadDispatcher._delayed.Count; i = num + 1) { DelayedQueueItem delayedQueueItem = MainThreadDispatcher._delayed[i]; bool flag2 = delayedQueueItem.time <= Time.time; if (flag2) { MainThreadDispatcher._currentDelayed.Add(delayedQueueItem); } num = i; } for (int j = 0; j < MainThreadDispatcher._currentDelayed.Count; j = num + 1) { DelayedQueueItem item = MainThreadDispatcher._currentDelayed[j]; MainThreadDispatcher._delayed.Remove(item); num = j; } for (int k = 0; k < MainThreadDispatcher._currentDelayed.Count; k = num + 1) { DelayedQueueItem delayedQueueItem2 = MainThreadDispatcher._currentDelayed[k]; delayedQueueItem2.action(); num = k; } } finally { Monitor.Exit(delayed); } } }