internal void StopInternal() { switch (State) { case ESimState.Construction: case ESimState.Elaboration: throw new InvalidOperationException("Model not yet elaborated"); case ESimState.Simulation: case ESimState.StopRequested: // inside simulation State = ESimState.StopRequested; CurrentProcess.Stop(); break; // not reached case ESimState.SimulationPaused: // outside simulation State = ESimState.StopRequested; CallSimulationStoppedHandlers(); State = ESimState.Stopped; break; case ESimState.Stopped: throw new InvalidOperationException("Simulation already stopped"); default: throw new NotImplementedException(); } }