private void Timer_Elapsed(object sender, ElapsedEventArgs e) { Elapsed = Elapsed.Add(TimeSpan.FromSeconds(1)); if (CurrentActivity == Activity.Working && Elapsed.TotalSeconds >= config.Working * 60) { AddHistory(Elapsed.TotalMinutes, true); pomodoros++; if (pomodoros == config.Pomorodos) { ChangeState(Activity.LongBreak); } else { ChangeState(Activity.ShortBreak); } } if ((CurrentActivity == Activity.ShortBreak && Elapsed.TotalSeconds >= config.ShortBreak * 60) || (CurrentActivity == Activity.LongBreak && Elapsed.TotalSeconds >= config.LongBreak * 60)) { AddHistory(Elapsed.TotalMinutes, false); ChangeState(Activity.Working); } }
public override void OnNext(TSource value) { lock (_gate) { var next = Elapsed.Add(_delay); _queue.Enqueue(new Reactive.TimeInterval <TSource>(value, next)); _evt.Release(); } }
public override void OnCompleted() { DisposeUpstream(); lock (_gate) { var next = Elapsed.Add(_delay); _completeAt = next; _hasCompleted = true; _evt.Release(); } }
private void Tick(object me, ElapsedEventArgs args) { Elapsed = Elapsed.Add(TimeSpan.FromSeconds(Speed)); if (PauseTime.HasValue && RealTime >= PauseTime.Value) { IsPaused = true; IsRealtime = ShowRealTimeWhenPaused; StopTick(); } if (IsCompleted) { StopTick(); } }
private void UpdateCounter() { //if (Elapsed.TotalMilliseconds >= StartTime.TotalMilliseconds) //{ // return; //} Elapsed = Elapsed.Add(TimeSpan.FromMilliseconds(+100)); ElapsedString = Elapsed.ToString(@"mm\:ss"); Current = StartTime.Subtract(Elapsed); if (Current.TotalMilliseconds <= StartTime.TotalMilliseconds * 0.4) { Background = Brushes.Red; } }
async void Timer_Elapsed(object sender, ElapsedEventArgs e) { Elapsed = Elapsed.Add(TimeSpan.FromSeconds(1)); if (IsRunning && Elapsed.TotalSeconds == pomodoroDutation * 60) { IsRunning = false; IsInBreak = true; Elapsed = TimeSpan.Zero; await SavePomodoroAsync(); } if (IsInBreak && Elapsed.TotalSeconds == pomodoroDutation * 60) { IsRunning = true; IsInBreak = false; Elapsed = TimeSpan.Zero; } }
public override void OnNext(TSource value) { var shouldRun = false; lock (_gate) { var next = Elapsed.Add(_delay); _queue.Enqueue(new Reactive.TimeInterval <TSource>(value, next)); shouldRun = _ready && !_active; _active = true; } if (shouldRun) { DrainQueue(_delay); } }
public override void OnCompleted() { DisposeUpstream(); var shouldRun = false; lock (_gate) { var next = Elapsed.Add(_delay); _completeAt = next; _hasCompleted = true; shouldRun = _ready && !_active; _active = true; } if (shouldRun) { DrainQueue(_delay); } }