static void OnTick() { TickEventHandler handler = Tick; if (handler != null) { handler((DateTime.Now - _startTime).TotalSeconds); } }
private void OnTick(object state) { var now = DateTime.Now; LastDeltaT = now - LastTick; LastTick = now; TickEventHandler?.Invoke(this, LastDeltaT); }
/// <inheritdoc /> public void Dispose() { var timerJobCompletionTask = this.timerJob.StopAsync(); var timerActionJobCompletionTask = this.timerActionJob.StopAsync(); Task.Run(() => { Task.WaitAll(timerJobCompletionTask, timerActionJobCompletionTask); timerJobCompletionTask.Dispose(); timerActionJobCompletionTask.Dispose(); this.timerRunningEvent.Dispose(); this.timerStoppedEvent.Dispose(); this.sleepCancellationTokenSource?.Dispose(); this.tick = null; }); }
/// <summary> /// Registers a new /// </summary> public void RegisterTickEventHandler(TickEventHandler tickEventHandler) { _simulationTimer.Tick += new EventHandler(tickEventHandler); }
/// <summary> /// Detaches a handler from the internal tick generator. /// </summary> /// <param name="handler"> /// The delegate to detach from the tick generator. /// </param> public void DetachFromClock(TickEventHandler handler) { tickGen.Tick -= handler; }
/// <summary> /// Attaches a handler to the internal tick generator. This allows /// outside sources to sync with the sequencer's playback. /// </summary> /// <param name="handler"> /// The delegate to attach to the tick generator. /// </param> public void AttachToClock(TickEventHandler handler) { tickGen.Tick += handler; }