Closed JasonNoonan closed 6 years ago
I have fixed this in my local module's files. I'll clean it up to match with your coding standards and send a merge request once I get some spare cycles.
Ooh! Thanks for catching that!
@JasonNoonan How is the PR coming?
I'll have to go double-check, but last time I looked at the code it appeared that the issue had already been resolved. Apologies for the delay, I've been pretty wrapped up in work.
Alright, non-zero chance that I'm an insane person and imagined seeing the fix. Away I go!
Expected Behavior
My coworker schedules the
!dilbert
command to fire every day at 7AM. I expect that on the next cycle after the scheduled time has passed, the command will be fired off.Current Behavior
When the ScheduledCommand is created and initialized, a StopWatch object is created and the timer is started. Every cycle, the StopWatch is checked to see if it is greater than the defined IntervalMS. This results in (for instance) a command that is scheduled to run at 7AM every day instead firing off daily at 2:45PM because that is when I happened to create the scheduled command.
Possible Solution
Modify the Scheduler logic so that the HasExpired method checks to see if the StartAfter property is less than the current date (which is currently being done after the IntervalMS check in the module). If so, fire off the command.
Modify the RestartTimer function to modify the StartAfter property with
$this.StartAfter.AddMilliseconds($IntervalMS)
so that the next run triggers correctlySteps to Reproduce (for bugs)
$IntervalMS
milliseconds after you created the command, not at the time you configured it to fire offYour Environment