From a46987aabfb175c7e3ec07b5887406aabecbbf76 Mon Sep 17 00:00:00 2001 From: Jeffery Thompson Date: Thu, 12 Jul 2018 15:09:52 -0400 Subject: [PATCH] refactor: UpdateRunTime -> GetNextRunTime, add UpdateRunTime for caching GetNextRunTime value - also swap the operands on the delta time calculation --- .../Services/Scheduler/AbstractScheduledAction.cs | 9 +++++++-- .../Services/Scheduler/ActionSchedulerService.cs | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ICD.Common.Utils/Services/Scheduler/AbstractScheduledAction.cs b/ICD.Common.Utils/Services/Scheduler/AbstractScheduledAction.cs index 0439f07..3cfbd2f 100644 --- a/ICD.Common.Utils/Services/Scheduler/AbstractScheduledAction.cs +++ b/ICD.Common.Utils/Services/Scheduler/AbstractScheduledAction.cs @@ -27,7 +27,12 @@ namespace ICD.Common.Utils.Services.Scheduler public void Run() { RunFinal(); - NextRunTime = UpdateRunTime(); + NextRunTime = GetNextRunTime(); + } + + public void UpdateNextRunTime() + { + NextRunTime = GetNextRunTime(); } /// @@ -38,6 +43,6 @@ namespace ICD.Common.Utils.Services.Scheduler /// /// Runs after RunFinal in order to set the next run time of this action /// - public abstract DateTime? UpdateRunTime(); + public abstract DateTime? GetNextRunTime(); } } \ No newline at end of file diff --git a/ICD.Common.Utils/Services/Scheduler/ActionSchedulerService.cs b/ICD.Common.Utils/Services/Scheduler/ActionSchedulerService.cs index ee59816..ea232a0 100644 --- a/ICD.Common.Utils/Services/Scheduler/ActionSchedulerService.cs +++ b/ICD.Common.Utils/Services/Scheduler/ActionSchedulerService.cs @@ -137,7 +137,7 @@ namespace ICD.Common.Utils.Services.Scheduler return; } - long msToNextAction = (long)(DateTime.Now - action.NextRunTime.Value).TotalMilliseconds; + long msToNextAction = (long)(action.NextRunTime.Value - DateTime.Now).TotalMilliseconds; m_Timer.Reset(msToNextAction); } finally