How to calculate interval for a timer thats only on a certain day of week.

Zexor

Well-known member
Joined
Nov 28, 2008
Messages
520
Programming Experience
3-5
I would like to setup a timer that only ticks within the desire dayofweek and time range. How do i calculate the interval? I would have 7 checkbox to select which day its on. A numericUpDown to show the start hour of those days. Another Nud to select the interval in minutes for the next tick. Another Nud to select how many ticks before it should stop trying. Basically it only ticks for a couple hours for each select days. It would need to recalculate the interval each time it ticks.
 
You create one DateTime for the current time and one for the time you want the Timer to Tick and subtract one from the other to create a TimeSpan. The TotalMilliseconds property of that gives you your Interval.
 
Back
Top