/// <summary> /// Updates the time of timing by delta time. /// </summary> /// <param name="deltaTime">The delta time.</param> public void Tick(float deltaTime) { if (TimerState != TimerState.Running) { return; } time += deltaTime; if (time < Interval) { return; } CurrentCount++; // Raise Ticking event Ticking?.Invoke(this, new TimerTickingEventArgs(CurrentCount)); if (RepeatCount != 0 && CurrentCount >= RepeatCount) { Reset(); OnCompleted?.Invoke(this, EventArgs.Empty); } time -= Interval; }
/// <summary> /// Updates the time of timing by delta time. /// </summary> /// <param name="deltaTime">The delta time.</param> public void Tick(float deltaTime) { if (TimerState != TimerState.Running) { return; } time += deltaTime; if (time >= Interval) { CurrentCount++; // Raise Ticking event if (Ticking != null) { Ticking.Invoke(this, new TimerTickingEventArgs(CurrentCount)); } if (RepeatCount != 0 && CurrentCount >= RepeatCount) { Reset(); if (Completed != null) { Completed.Invoke(this, EventArgs.Empty); } } time = time - Interval; } }
public void Start() { CancellationTokenSource cts = _cancellationTokenSource; foreach (var ts in _timeSpanList) { Device.StartTimer(ts, () => { if (cts.IsCancellationRequested) { return(false); } var result = _callback.Invoke(); Ticking?.Invoke(null, EventArgs.Empty); return(result); }); } }
protected virtual void OnTicking(PlayerEventArgs e) { Ticking?.Invoke(this, e); }