private static void ProcessIntervals() { // ToList will snapshot the keys, so we don't run new timers created by these timers in this loop foreach (string guid in intervalTimers.Keys.ToList()) { // handle things in this current function call removing other timers if (!intervalTimers.ContainsKey(guid)) { continue; } TimerCallback timerCallback = intervalTimers[guid]; if (!timerCallback.IsTimeUp()) { continue; } JavaScriptValue callback = timerCallback.callback; try { callback.CallFunction(JavaScriptValue.Undefined); } catch (Exception e) { UnityEngine.Debug.LogError(e); } timerCallback.stopwatch.Restart(); } }