/// <summary> /// Initializes if needed, issues updates. /// </summary> public override void UpdateAfterSimulation() { MainLock.MainThread_TryReleaseExclusive(); try { switch (MangerStatus) { case Status.Not_Initialized: //myLogger.debugLog("Not Initialized", "UpdateAfterSimulation()"); Init(); return; case Status.Terminated: return; } foreach (KeyValuePair <uint, List <Action> > pair in UpdateRegistrar) { if (Update % pair.Key == 0) { foreach (Action item in pair.Value) { try { item.Invoke(); } catch (Exception ex2) { myLogger.log("Script threw exception, unregistering: " + ex2, "UpdateAfterSimulation()", Logger.severity.ERROR); UnRegisterForUpdates(pair.Key, item); } } } } } catch (Exception ex) { myLogger.log("Exception: " + ex, "UpdateAfterSimulation()", Logger.severity.FATAL); MangerStatus = Status.Terminated; } finally { Update++; MainLock.MainThread_TryAcquireExclusive(); } }
public override void UpdateBeforeSimulation() { if (delayStart > 0) { delayStart--; return; } MainLock.MainThread_TryReleaseExclusive(); try { if (isUpdating || terminated) { return; } isUpdating = true; //MyAPIGateway.Parallel.Start(doUpdate, updateCallback); doUpdate(); isUpdating = false; } finally { MainLock.MainThread_TryAcquireExclusive(); } }