/// <summary> /// Event handler. Used to update the form when the worker reports progress. /// </summary> private void workerReport(object sender, ProgressChangedEventArgs args) { TestWorker wrkr = sender as TestWorker; TestProgress progress = (TestProgress)args.UserState; EstimateTimeRemaining(progress); percLabel.Text = Convert.ToString(args.ProgressPercentage) + "%" + " (" + progress.TestsComplete + "/" + progress.TestsToDo + ")"; progressBarTests.Increment(args.ProgressPercentage - percOnlastUpdate); percOnlastUpdate = args.ProgressPercentage; this.Refresh(); }
private void EstimateTimeRemaining(TestProgress progress) { currentIterations++; if (currentIterations >= ITERATIONS_PER_ESTIMATION) { TimeSpan currentTimeEstimate = TimeSpan.FromTicks(progress.AverageTestDuration.Ticks * (progress.TestsToDo - progress.TestsComplete)); string timeString = ""; if (currentTimeEstimate.Hours != 0) { timeString += currentTimeEstimate.Hours + " hour(s), "; } if (currentTimeEstimate.Minutes != 0) { timeString += currentTimeEstimate.Minutes + " minute(s), "; } timeString += currentTimeEstimate.Seconds + " second(s)"; timeRemainingLabel.Text = timeString; currentIterations = 0; } }