Esempio n. 1
0
        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));
        }
Esempio n. 2
0
        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();
        }
Esempio n. 3
0
 protected virtual void OnRoundResting(ReportUpdateEventArgs eventArgs)
 {
     RoundResting?.Invoke(eventArgs);
 }
Esempio n. 4
0
 protected virtual void OnRoundStarted(ReportUpdateEventArgs eventArgs)
 {
     RoundStarted?.Invoke(eventArgs);
 }