private static void LaunchBasicEvent(EventHandler <EvolutionEventsArgs> currentEvent, string userName) { // Always check that there are listeners for the event if (null != currentEvent) { // Catches exceptions thrown by event listeners. This prevents // listener exceptions from terminating the algorithm thread. try { EvolutionEventsArgs myArguments = new EvolutionEventsArgs(); myArguments.userName = userName; currentEvent(null, myArguments); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("EventsController: Event threw exception" + ex); } } }
public static void RaiseSaveCandidate(int candidateIndex, string folderName, string userName) { LookForEvolutionAlgorithm(userName); // Always check that there are listeners for the event if (null != SaveCandidate) { // Creates here the arguments for the event EvolutionEventsArgs myArguments = new EvolutionEventsArgs(); myArguments.userName = userName; myArguments.candidateIndex = candidateIndex; myArguments.folderName = folderName; // Catches exceptions thrown by event listeners. This prevents // listener exceptions from terminating the algorithm thread. try { SaveCandidate(null, myArguments); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("SaveCandidateEvent listener threw exception" + ex); } } }