/// <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(); } }
private void NotifyTimerElapsed(Object source, ElapsedEventArgs e) { OnTimerTicked?.Invoke(); }
/// <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; }
/// <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; }