예제 #1
0
                /// <summary>
                /// Creates and initializes a new instance of a Timer.
                /// </summary>
                internal Timer(float waitTime, Timer.OnTimerFinished onTimerFinished = null, Timer.OnTimerTicked onTimerTicked = null, bool startNow = true)
                {
                    SetWaitTime(waitTime);
                    this.onTimerFinished = onTimerFinished;
                    this.onTimerTicked   = onTimerTicked;

                    if (startNow)
                    {
                        Start();
                    }
                    else
                    {
                        Pause();
                    }
                }
예제 #2
0
 private void NotifyTimerElapsed(Object source, ElapsedEventArgs e)
 {
     OnTimerTicked?.Invoke();
 }
예제 #3
0
 /// <summary>
 /// Sets the delegate to invoke when the timer ticks.
 /// When the timer has finished and/or you don't need it anymore, don't forget to call RemoveListener.
 /// </summary>
 public void AddListener(OnTimerTicked delgt)
 {
     onTimerTicked += delgt;
 }
예제 #4
0
 /// <summary>
 /// Removes the specified delegate from the delegate invokation list.
 /// This should be called in cases where you want to unsubscribe a function.
 public void RemoveListener(OnTimerTicked delgt)
 {
     onTimerTicked -= delgt;
 }
 internal Timer(float waitTime, Timer.OnTimerFinished onTimerFinished = null, Timer.OnTimerTicked onTimerTicked = null)
 {
     SetWaitTime(waitTime);
     this.onTimerFinished = onTimerFinished;
     this.onTimerTicked   = onTimerTicked;
 }