コード例 #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;
 }
コード例 #5
0
 internal Timer(float waitTime, Timer.OnTimerFinished onTimerFinished = null, Timer.OnTimerTicked onTimerTicked = null)
 {
     SetWaitTime(waitTime);
     this.onTimerFinished = onTimerFinished;
     this.onTimerTicked   = onTimerTicked;
 }