public void BroadcastReset() { this.LogTrace("BroadcastReset() start"); // Block instantiation and registration that may inadvertently // be attempted by Reset() in one of our registered instances _resetInProgress = true; _instantiator.SetResetInProgress(_resetInProgress); _coroutineCreatorProvider.Get().SetResetInProgress(_resetInProgress); if (_onReset != null) { this.LogTrace("Firing OnReset() ..."); _onReset(); } // Reset the registered instances in the reverse order they were registered. // This returns a copy of the underlying LinkedList, so we can modify the original // list without issue. foreach (ILifecycleAware targetInstance in _registeredInstances.GetListReversed()) { this.LogTrace("Reset() " + targetInstance.GetName()); try { // We make a best effort to reset all instances, even if Reset() throws an exception in a registered instance targetInstance.Reset(); } catch (Exception e) { this.LogError("Exception in Reset() on '" + targetInstance.GetName() + "': " + e.ToString()); } } // Apply any global unloading logic ResetGlobalState(); _resetInProgress = false; _instantiator.SetResetInProgress(_resetInProgress); this.LogTrace("BroadcastReset() end"); this.LogTrace("~".Repeat(80)); }