fix: The SafeTimer constructor that executes the callback immediately now works as expected

This commit is contained in:
Austin Noska
2021-01-20 17:46:26 -05:00
committed by Chris Cameron
parent c1b9426e32
commit d090ab0085
3 changed files with 6 additions and 12 deletions

View File

@@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
## [Unreleased]
### Changed
- A SafeTimer constructor that executes the callback immediately now does this instead of waiting infinitely
## [14.0.0] - 2021-01-14
### Added
- Added Get and Set extensions to PropertyInfo in SIMPLSHARP to mimic overloads avaliable in NETSTANDARD

View File

@@ -18,9 +18,9 @@ namespace ICD.Common.Utils.Services.Scheduler
public ActionSchedulerService()
{
m_Actions = new List<IScheduledAction>();
m_Timer = new SafeTimer(TimerCallback, -1);
m_CriticalSection = new SafeCriticalSection();
m_LastRunTime = DateTime.MinValue;
m_Timer = SafeTimer.Stopped(TimerCallback);
}
public void Dispose()
@@ -153,15 +153,6 @@ namespace ICD.Common.Utils.Services.Scheduler
}
}
private void Log(eSeverity severity, string message, params object[] args)
{
ILoggerService logger = ServiceProvider.TryGetService<ILoggerService>();
if (logger == null)
return;
logger.AddEntry(severity, string.Format("{0} - {1}", this, message), args);
}
private void Log(eSeverity severity, Exception ex, string message, params object[] args)
{
ILoggerService logger = ServiceProvider.TryGetService<ILoggerService>();

View File

@@ -36,7 +36,7 @@ namespace ICD.Common.Utils.Timers
/// <param name="callback"></param>
/// <param name="repeatPeriod"></param>
public SafeTimer(Action callback, long repeatPeriod)
: this(callback, -1, repeatPeriod)
: this(callback, 0, repeatPeriod)
{
}
@@ -138,7 +138,7 @@ namespace ICD.Common.Utils.Timers
if (repeatPeriod < 0 && repeatPeriod != Timeout.Infinite)
throw new ArgumentOutOfRangeException("repeatPeriod", "Repeat period must be greater than or equal to 0ms");
if (dueTime >= int.MaxValue)
if (repeatPeriod >= int.MaxValue)
throw new ArgumentOutOfRangeException("repeatPeriod", string.Format("Repeat period must be less than {0:n0}ms", int.MaxValue));
#if SIMPLSHARP