diff --git a/_src/Implementation/Time/DefaultStopwatch.cs b/_src/Implementation/Time/DefaultStopwatch.cs index 3382769..ac573ab 100644 --- a/_src/Implementation/Time/DefaultStopwatch.cs +++ b/_src/Implementation/Time/DefaultStopwatch.cs @@ -105,11 +105,17 @@ public void Reset() } } - public void PeriodicOperation(int periodInMilliseconds, ITickListener listener, CancellationToken cancellationToken) + public IPeriodicStopwatch PeriodicOperation(int periodInMilliseconds, ITickListener listener, CancellationToken cancellationToken) { var periodicStopwatch = new PeriodicStopwatch(this, periodInMilliseconds, listener, cancellationToken); _periodicStopwatches.Add(periodicStopwatch); periodicStopwatch.Start(); + return periodicStopwatch; + } + + public IPeriodicStopwatch PeriodicOperation(int periodInMilliseconds, ITickListener listener) + { + return PeriodicOperation(periodInMilliseconds, listener, _cancellationToken); } public IPeriodicStopwatchFactory GetPeriodicStopwatchFactory() diff --git a/_src/Infrastructure/Time/IStopwatch.cs b/_src/Infrastructure/Time/IStopwatch.cs index 7ed7910..52409ec 100644 --- a/_src/Infrastructure/Time/IStopwatch.cs +++ b/_src/Infrastructure/Time/IStopwatch.cs @@ -10,7 +10,8 @@ public interface IStopwatch : IAdjustableStopwatch, IDisposable { void Wait(int periodInMilliseconds, ITickListener listener); Task WaitAsync(int periodInMilliseconds, ITickListener listener); - void PeriodicOperation(int periodInMilliseconds, ITickListener listener, CancellationToken cancellationToken); + IPeriodicStopwatch PeriodicOperation(int periodInMilliseconds, ITickListener listener, CancellationToken cancellationToken); + IPeriodicStopwatch PeriodicOperation(int periodInMilliseconds, ITickListener listener); IPeriodicStopwatchFactory GetPeriodicStopwatchFactory(); void RegisterStopwatch(IPeriodicStopwatch stopwatch); void UnregisterStopwatch(IPeriodicStopwatch stopwatch);