示例#1
0
        static void OnTick()
        {
            TickEventHandler handler = Tick;

            if (handler != null)
            {
                handler((DateTime.Now - _startTime).TotalSeconds);
            }
        }
示例#2
0
        private void OnTick(object state)
        {
            var now = DateTime.Now;

            LastDeltaT = now - LastTick;
            LastTick   = now;

            TickEventHandler?.Invoke(this, LastDeltaT);
        }
示例#3
0
        /// <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;
            });
        }
示例#4
0
 /// <summary>
 /// Registers a new 
 /// </summary>
 public void RegisterTickEventHandler(TickEventHandler tickEventHandler)
 {
     _simulationTimer.Tick += new EventHandler(tickEventHandler);
 }
示例#5
0
 /// <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;
 }                                  
示例#6
0
 /// <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;
 }
示例#7
0
 /// <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;
 }
示例#8
0
 /// <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;
 }