diff --git a/ICD.Common.Utils/Timers/Repeater.cs b/ICD.Common.Utils/Timers/Repeater.cs
index 1ad2332..236208e 100644
--- a/ICD.Common.Utils/Timers/Repeater.cs
+++ b/ICD.Common.Utils/Timers/Repeater.cs
@@ -1,6 +1,5 @@
using System;
using ICD.Common.Properties;
-using ICD.Common.Utils.Extensions;
namespace ICD.Common.Utils.Timers
{
@@ -11,36 +10,20 @@ namespace ICD.Common.Utils.Timers
[PublicAPI]
public sealed class Repeater : IDisposable
{
- ///
- /// Raised on the initial repeat.
- ///
- [PublicAPI]
- public event EventHandler OnInitialRepeat;
-
- ///
- /// Raised on each subsequent repeat.
- ///
- [PublicAPI]
- public event EventHandler OnRepeat;
+ public delegate void RepeatCallback(bool isInitial);
private readonly SafeTimer m_RepeatTimer;
- private readonly long m_BeforeRepeat;
- private readonly long m_BetweenRepeat;
+ private RepeatCallback m_RepeatCallback;
#region Constructor
///
/// Constructor.
///
- /// The delay before the second increment
- /// The delay between each subsequent repeat
- public Repeater(long beforeRepeat, long betweenRepeat)
+ public Repeater()
{
- m_RepeatTimer = SafeTimer.Stopped(RepeatCallback);
-
- m_BeforeRepeat = beforeRepeat;
- m_BetweenRepeat = betweenRepeat;
+ m_RepeatTimer = SafeTimer.Stopped(TimerElapsed);
}
///
@@ -66,12 +49,21 @@ namespace ICD.Common.Utils.Timers
///
/// Begin repeating.
///
+ ///
+ /// The delay before the second increment
+ /// The delay between each subsequent repeat
[PublicAPI]
- public void Start()
+ public void Start([NotNull] RepeatCallback repeatCallback, long beforeRepeat, long betweenRepeat)
{
- OnInitialRepeat.Raise(this);
+ if (repeatCallback == null)
+ throw new ArgumentNullException("repeatCallback");
- m_RepeatTimer.Reset(m_BeforeRepeat, m_BetweenRepeat);
+ Stop();
+
+ m_RepeatCallback = repeatCallback;
+ m_RepeatCallback(true);
+
+ m_RepeatTimer.Reset(beforeRepeat, betweenRepeat);
}
///
@@ -81,6 +73,7 @@ namespace ICD.Common.Utils.Timers
public void Stop()
{
m_RepeatTimer.Stop();
+ m_RepeatCallback = null;
}
#endregion
@@ -90,9 +83,9 @@ namespace ICD.Common.Utils.Timers
///
/// Called for every repeat.
///
- private void RepeatCallback()
+ private void TimerElapsed()
{
- OnRepeat.Raise(this);
+ m_RepeatCallback(false);
}
#endregion