void Defer_OnTick(object sender, EventArgs e) { WorkerData.Clear(); int i = 0; foreach (var worker in _workers) { string d = "Worker " + i.ToString(); if (worker.Busy) { d += " - assigned: " + worker.Source; } else { d += " - free"; } i++; WorkerData.Add(d); } try { foreach (var action in Actions) { try { action(); } catch (Exception ex) { Game.DisplayTextBox("A deferred script caused an exception."); Initialize.Log("Exception caused in deferred script: " + ex.ToString()); } } Actions.Clear(); } catch (InvalidOperationException) { } }
void DeferredScript_OnTick(object sender, EventArgs e) { if (_action == null) { return; } try { _action(); } catch (Exception ex) { Game.DisplayTextBox("A deferred script caused an exception."); Initialize.Log("Exception caused in deferred script: " + ex.ToString()); } _action = null; }