static void WhenPauseEvent(object sender, EvolutionEventsArgs arguments) { string userName = arguments.userName; // In this version we decide to stop the program at a pause event. // evolutionRunning = false here seems reiterative? (see TryStopEvolution) ActiveUsersList <NeatGenome> .SetRunningStatus(userName, false); SaveDataIfRunning(userName); }
private static void TryStopEvolution(string userName) { // We should not be able to ask to stop a process that has not started! // (And thus we ALWAYS expect this check to be true) if (ActiveUsersList <NeatGenome> .ContainsUser(userName)) { if (ActiveUsersList <NeatGenome> .IsUserRunning(userName)) { System.Diagnostics.Debug.WriteLine("Stopping evolution process..."); ActiveUsersList <NeatGenome> .SetRunningStatus(userName, false); ActiveUsersList <NeatGenome> .EvolutionAlgorithmForUser(userName).StopEvolution(); } else { System.Diagnostics.Debug.WriteLine("Evolution is already stopped: skipping stop."); } } else { System.Diagnostics.Debug.WriteLine("Requested to stop " + userName + " but it was not found in the dictionary!"); } }
static void SetEvolutionStatusRunning(string userName) { ActiveUsersList <NeatGenome> .SetRunningStatus(userName, true); System.Diagnostics.Debug.WriteLine("User: "******". Start evolution: " + DateTime.Now.ToString() + "\n"); }