/// <summary> /// Measures the subject and also raises the needed events. /// The additional values are calculated from the measured data. /// </summary> /// <returns>A <see cref="KinokoResult"/> object containing the measured data.</returns> /// <param name='task'>The kinoko task to be run.</param> /// <param name='repeatCount'>The number of times to repeat the measurement.</param> private KinokoResult RunTaskAndRaiseEvents(KinokoTask task, int repeatCount) { OnTaskRunning(new TaskRunningEventArgs(task)); KinokoResult result = RunTask(task, repeatCount); OnTaskRun(new TaskRunEventArgs(result)); return(result); }
/// <summary> /// Runs the task multiple times and measures the time intervals spent. /// </summary> /// <param name="task">The kinoko task to be run.</param> /// <param name="repeatCount">Specifies the number of times to repeat the measurement.</param> /// <returns>A <see cref="KinokoResult"/> object containing the measured data and the calculated values.</returns> /// <remarks> /// After the measurements are finished, additional values (for example the average) are calculated from the measured data. /// </remarks> public KinokoResult Run(KinokoTask task, int repeatCount) { if (task == null) { throw new ArgumentNullException("task"); } if (repeatCount < 1) { throw new ArgumentOutOfRangeException("repeatCount", "The repeat count should be an integer greater then 0."); } return(RunTaskAndRaiseEvents(task, repeatCount)); }
private KinokoResult RunTask(KinokoTask task, int repeatCount) { Measurer measurer = new Measurer(task.Subject, repeatCount); measurer.Measuring += HandleMeasurerMeasuring; measurer.Measured += HandleMeasurerMeasured; try { return(measurer.Run()); } finally { measurer.Measuring -= HandleMeasurerMeasuring; measurer.Measured -= HandleMeasurerMeasured; } }
/// <summary> /// Initializes a new instance of the <see cref="TaskRunningEventArgs"/> class. /// </summary> /// <param name="task">The task that is about to be run.</param> public TaskRunningEventArgs(KinokoTask task) { this.task = task; }