public void Update(double timeSpeedMultiply = 1) { if (_running == false) { return; } IntervalLeft -= GeneralOptions.GameTime.ElapsedGameTime.Milliseconds * timeSpeedMultiply; if (IntervalLeft > 0) { return; } if (_runningToEnd) { return; } OnElapsed?.Invoke(this, null); if (IsRepeater) { IntervalLeft = IntervalMax; } else { Stop(); } }
private void NotifyTimerElapsed(Object source, ElapsedEventArgs e) { if (LoadingState == LoadingComponentState.Show) { Timer = Timer.AddMilliseconds(10); } OnElapsed?.Invoke(Timer); }
private void NotifyTimerElapsed(object source, ElapsedEventArgs e) { OnElapsed?.Invoke(); if (!_timer.AutoReset) { _timer.Stop(); _timer.Dispose(); _timer = null; } }
public Debouncer(OnElapsed onElapsed, T initialValue, int milliseconds = 200) { Value = initialValue; _debouncer = new Timer(milliseconds); _debouncer.Stop(); _debouncer.AutoReset = false; _debouncer.Elapsed += (_, __) => { lock (_valueLock) { onElapsed.Invoke(Value); } }; }
private void DoTimer() { try { int last = Environment.TickCount; while (_IsStart) { if (Environment.TickCount - last > _Interval) { OnElapsed?.Invoke(); last = Environment.TickCount; } Thread.Sleep(100); } } catch (Exception e) { log.Error("定时DoTimer()出错:" + e.Message.ToString()); } }
private void onCoreTimerTick(object sender, EventArgs e) { if (elapsed < time) { elapsed += interval; double ratio = (double)elapsed / time; OnTick?.Invoke(ratio); } else { OnElapsed?.Invoke(); if (isRepeating) { elapsed = 0; } else { coreTimer.Stop(); isRunning = false; } } }
private void SetupTimer(double interval, int playCount, Action <int> intervalAction, bool dispose) { if (!IsValidTimeInterval(interval) || intervalAction == null || playCount <= 0) { return; } timer.Interval = interval; this.playCount = playCount; counter = 0; timer.AutoReset = playCount != 1; timer.Elapsed += (object sender, ElapsedEventArgs e) => { counter++; intervalAction(counter); OnElapsed?.Invoke(counter); if (counter >= playCount && playCount > 0) { StopTimer(dispose); } }; }
private void NotifyTimerElapsed(Object source, ElapsedEventArgs e) { OnElapsed?.Invoke(); _timer.Dispose(); }
private void NotifyTimerElapsed(object source, ElapsedEventArgs e) { OnElapsed?.Invoke(); }
public void OperationScheduleElapsed() { OnElapsed?.Invoke(); }
private void NotifyTimerElapsed(Object source, System.Timers.ElapsedEventArgs e) { OnElapsed?.Invoke(); }