private static bool InitializeExperiment(XmlDocument config) { // Termine any ongoing experiment, or the algorithm thread will block indefinitely and leak _experiment?.Terminate(); if (config == null) { Console.WriteLine("Config was null, aborting..."); return(false); } Assembly assembly = Assembly.GetExecutingAssembly(); XmlElement xmlConfig = config.DocumentElement; _experimentType = assembly.GetType(XmlUtils.GetValueAsString(xmlConfig, "ExperimentClass"), false, false); _experiementCount = XmlUtils.TryGetValueAsInt(xmlConfig, "ExperimentCount") ?? 1; _experiment = (IExperiment)Activator.CreateInstance(_experimentType); string name = XmlUtils.GetValueAsString(xmlConfig, "Name"); _logger.Info($"Initializing experiment: {name}..."); // Register event listeners _experiment.ExperimentStartedEvent += ExperimentStartedEvent; _experiment.ExperimentPausedEvent += ExperimentPausedEvent; _experiment.ExperimentResumedEvent += ExperimentResumedEvent; _experiment.ExperimentCompleteEvent += ExperimentCompleteEvent; _experimentStartedTime = DateTime.Now; _experiment.Initialize(name, xmlConfig, _identifier, _currentConfig, _currentExperiment); return(true); }