public void OnTimerEvent() { if (!OnPause && Step * DeltaTime % 1 < Tolerance) { OnTimer?.Invoke(this, new EventArgs()); } }
public override bool Update() { if (!_running) { return(false); } if (_pause) { return(true); // do NOT remove us from the list of ops to update } _remaining -= Time.deltaTime; RemainingTime.Value = _remaining; if (_remaining <= 0.0f) { OnTimer.Invoke(); if (OneShot) { return(false); } else { Start(); return(true); } } else { return(true); } }
protected virtual void Update() { _currentTime += Time.deltaTime; OnTimer.Invoke(timer - _currentTime); OnNormalizedTimer.Invoke(_currentTime / timer); if (_currentTime >= timer) { OnTimerEnd.Invoke(); enabled = false; } }
private void DoWork() { try { OnTimer?.Invoke(this, EventArgs.Empty); } catch (Exception e) { _logger.LogError(e, "Error in timer invoke"); } _reaperTimer.Change(_timerInterval, int.MaxValue); }
public void TimerCallback(UInt32 timer_id, UInt32 msg, UIntPtr user_ctx, UIntPtr reserve1, UIntPtr reserve2) { if (timer_id != this.TimerID) { throw new InvalidOperationException($"incoming timer id[{timer_id}] != my TimerID[{TimerID}] !!"); } TimerEventArgs arg = new TimerEventArgs(); LastTickTime = arg.SignalTime; OnTimer?.Invoke(this, arg); }
public void FunctionTimer() { Stopwatch watch = new Stopwatch(); watch.Start(); while (EventStopWait.Wait(Period)) { watch.Stop(); if (watch.ElapsedMilliseconds >= Period) { watch.Reset(); var arg = new TimerEventArgs(); this.LastSignalTime = arg.SignalTime; OnTimer?.Invoke(this, arg); } watch.Start(); } //multimedia }
void Tick(HeartBeatEventType eventType) { OnTimer?.Invoke(this, new HeartBeatEventArgs(eventType)); }
public MakiTimer() { timer.Elapsed += (a, b) => OnTimer?.Invoke(); }
private void TimerProc(UInt32 id, UInt32 msg, UIntPtr userCtx, UIntPtr rsv1, UIntPtr rsv2) { OnTimer?.Invoke(this, new EventArgs()); }
private void Loop() { _nextWakeUpTickTime = Stopwatch.GetTimestamp(); try { while (true) { _nextWakeUpTickTime += _cycleTimeInTicks; while (true) { long ticks = _nextWakeUpTickTime - Stopwatch.GetTimestamp(); if (ticks <= 0L) { break; } long diff = (ticks * 1000) / Stopwatch.Frequency; // cycle in milliseconds if (diff >= 100) { Thread.Sleep(20); } else if (diff >= 40) { Thread.Sleep(10); } else if (diff >= 25) { Thread.Sleep(2); } else if (diff >= 15) { Thread.Sleep(1); } else if (diff >= 5) { Thread.SpinWait(200); } else if (diff > 1) { Thread.SpinWait(100); } else { Thread.SpinWait(10); } } long lDelay = Stopwatch.GetTimestamp() - _nextWakeUpTickTime; if (lDelay < _MaxDelayInTicks) { OnTimer?.Invoke(null, null); } else { OnSkipped?.Invoke(null, null); } } } catch (ThreadInterruptedException) { } catch (Exception) { Console.WriteLine("Exiting timer thread."); } OnStoped?.Invoke(null, null); }
// Вызов события таймера void Timer() { secondsAlive++; OnTimer?.Invoke(); }
public string SetTimer() { OnTimer?.Invoke(GetFirstMessage()); return(null); }
protected void RaiseTimerEvent(int cyclesPerSecond) { OnTimer?.Invoke(cyclesPerSecond); }