private void OnRoundResting(ReportUpdateEventArgs eventArgs) { Console.Beep(3000, 500); var entries = new[] { new LogEntry("Resting after round ", true, false), new LogEntry($"#{eventArgs.Round}", false, false, SystemColors.Highlight), new LogEntry(" for ", false, false), new LogEntry($"{eventArgs.Time.TotalSeconds:N0}", false, false, SystemColors.Highlight), new LogEntry(" seconds.", false) }; _mainLogProvider.Log(LogItem.Create(entries)); }
public override async Task Start() { CancellationTokenSource = new CancellationTokenSource(); var cancellationToken = CancellationTokenSource.Token; var stopwatch = Stopwatch.StartNew(); try { if (PreparationTime.Seconds != 0) { OnPreparing(PreparationTime); await Task.Delay(PreparationTime, cancellationToken); } ReportUpdateEventArgs eventArgs; for (var round = 1; round < Rounds; round++) { eventArgs = new ReportUpdateEventArgs(round, TimeOn, stopwatch.Elapsed); OnRoundStarted(eventArgs); await Task.Delay(TimeOn, cancellationToken); if (round == Rounds) { break; } eventArgs = new ReportUpdateEventArgs(round, TimeOff, stopwatch.Elapsed); OnRoundResting(eventArgs); await Task.Delay(TimeOff, cancellationToken); } eventArgs = new ReportUpdateEventArgs(Rounds, LastRoundTime, stopwatch.Elapsed); OnRoundStarted(eventArgs); await Task.Delay(LastRoundTime, cancellationToken); } catch (Exception) { stopwatch.Stop(); OnStopped(stopwatch.Elapsed); return; } stopwatch.Stop(); OnFinished(stopwatch.Elapsed); Dispose(); }
protected virtual void OnRoundResting(ReportUpdateEventArgs eventArgs) { RoundResting?.Invoke(eventArgs); }
protected virtual void OnRoundStarted(ReportUpdateEventArgs eventArgs) { RoundStarted?.Invoke(eventArgs); }