-
-
Notifications
You must be signed in to change notification settings - Fork 108
Description
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 correctly
Steps to Reproduce (for bugs)
- Create a scheduled command, with a "StartAfter" value that is different from the increment amount
- Wait for the command to fire off
- Observe that the command is fired off
$IntervalMSmilliseconds after you created the command, not at the time you configured it to fire off
Your Environment
- Module version used: 0.10.2
- Operating System and PowerShell version: Windows 10 (1803) - PowerShell v5.1