private void CheckForTimeout(object sender, TimerTickEventArgs e) { bool isRunning = _timeout > TimeSpan.Zero; if (!isRunning) { return; } _timeout -= e.ElapsedTime; bool isElapsed = _timeout <= TimeSpan.Zero; if (!isElapsed) { return; } try { _action?.Invoke(); } finally { if (_interval == TimeSpan.Zero) { Cancel(); } else { _timeout = _interval; } } }
private void Tick(object sender, TimerTickEventArgs e) { if (_ledTimeout.IsRunning) { _ledTimeout.Tick(e.ElapsedTime); if (_ledTimeout.IsElapsed) { ToggleStatusLed(); } } _durations.Add((int)e.ElapsedTime.TotalMilliseconds); if (_durations.Count == _durations.Capacity) { _averageTimerDuration = _durations.Sum() / (float)_durations.Count; _durations.Clear(); _systemInformationService.Set("Health/SystemTime", DateTime.Now); if (!_maxTimerDuration.HasValue || _averageTimerDuration > _maxTimerDuration.Value) { _maxTimerDuration = _averageTimerDuration; _systemInformationService.Set("Health/TimerDurationAverageMax", _averageTimerDuration); } if (!_minTimerDuration.HasValue || _averageTimerDuration < _minTimerDuration.Value) { _minTimerDuration = _averageTimerDuration; _systemInformationService.Set("Health/TimerDurationAverageMin", _averageTimerDuration); } } }
private void Tick(object sender, TimerTickEventArgs e) { if (!_timeout.IsRunning) { return; } _timeout.Tick(e); if (_timeout.IsElapsed) { _timeInLitterBox.Stop(); Task.Run(() => Tweet(_timeInLitterBox.Elapsed)); } }
private void ApplyFrame(object sender, TimerTickEventArgs timerTickEventArgs) { _position += timerTickEventArgs.ElapsedTime; ApplyFrame(); }
public void Tick(TimerTickEventArgs timerTickEventArgs) { if (timerTickEventArgs == null) throw new ArgumentNullException(nameof(timerTickEventArgs)); Tick(timerTickEventArgs.ElapsedTime); }
private void UpdatePosition(TimerTickEventArgs timerTickEventArgs) { var activeState = GetState(); if (activeState.Equals(RollerShutterStateId.MovingUp)) { _position -= (int)timerTickEventArgs.ElapsedTime.TotalMilliseconds; } else if (activeState.Equals(RollerShutterStateId.MovingDown)) { _position += (int)timerTickEventArgs.ElapsedTime.TotalMilliseconds; } if (_position < 0) { _position = 0; } if (_position > Settings.MaxPosition) { _position = Settings.MaxPosition; } }
private void CheckForTimeout(object sender, TimerTickEventArgs e) { if (!_stopwatch.IsRunning) { return; } if (_stopwatch.Elapsed > Settings.PressedLongDuration) { _stopwatch.Stop(); OnPressedLong(); } }