//-------------------------------------------------------------------------------------------------// public virtual ExperimentResultInfo Execute(ExperimentSpecification experimentSpecification) { const string STRLOG_MethodName = "Execute"; Logfile.WriteCalled(STRLOG_ClassName, STRLOG_MethodName); // // Create an instance of the experiment result info ready to fill in // ExperimentResultInfo experimentResultInfo = new ExperimentResultInfo(); try { // Determine time to finish execution DateTime dateTimeEnd = DateTime.Now + new TimeSpan(0, 0, EXECUTION_TIME); // // Delay for the full execution time, unless cancelled // while (DateTime.Now < dateTimeEnd) { Trace.Write("M"); Thread.Sleep(1000); // // Check if the experiment is being cancelled // if (this.cancelExperiment != null && this.cancelExperiment.IsCancelled == true) { // Experiment is cancelled experimentResultInfo.statusCode = StatusCodes.Cancelled; break; } } Trace.WriteLine(""); // // Check if the experiment was cancelled // if (experimentResultInfo.statusCode != StatusCodes.Cancelled) { // Successful execution experimentResultInfo.statusCode = StatusCodes.Completed; } } catch (Exception ex) { experimentResultInfo.statusCode = StatusCodes.Failed; experimentResultInfo.errorMessage = ex.Message; Logfile.WriteError(ex.Message); } Logfile.Write(STRLOG_StatusCode + experimentResultInfo.statusCode); Logfile.WriteCompleted(STRLOG_ClassName, STRLOG_MethodName); return experimentResultInfo; }
//-------------------------------------------------------------------------------------------------// public virtual ExperimentResultInfo Execute(ExperimentSpecification experimentSpecification) { const string STRLOG_MethodName = "Execute"; Logfile.WriteCalled(STRLOG_ClassName, STRLOG_MethodName); // // Create an instance of the experiment result info ready to fill in // ExperimentResultInfo experimentResultInfo = new ExperimentResultInfo(); try { // Determine time to finish execution DateTime dateTimeEnd = DateTime.Now + new TimeSpan(0, 0, EXECUTION_TIME); // // Delay for the full execution time, unless cancelled // while (DateTime.Now < dateTimeEnd) { Trace.Write("M"); Thread.Sleep(1000); // // Check if the experiment is being cancelled // if (this.cancelExperiment != null && this.cancelExperiment.IsCancelled == true) { // Experiment is cancelled experimentResultInfo.statusCode = StatusCodes.Cancelled; break; } } Trace.WriteLine(""); // // Check if the experiment was cancelled // if (experimentResultInfo.statusCode != StatusCodes.Cancelled) { // Successful execution experimentResultInfo.statusCode = StatusCodes.Completed; } } catch (Exception ex) { experimentResultInfo.statusCode = StatusCodes.Failed; experimentResultInfo.errorMessage = ex.Message; Logfile.WriteError(ex.Message); } Logfile.Write(STRLOG_StatusCode + experimentResultInfo.statusCode); Logfile.WriteCompleted(STRLOG_ClassName, STRLOG_MethodName); return(experimentResultInfo); }