0

There are solutions to run scheduler to start triggering. But my requirement is to trigger at the end time also.

I have a schedule input like below:-

Scheduler Input

  1. I have to resume a progress when scheduled time starts.
  2. I have to suspend it when there is a break in between effective scheduled date range.and resume after the break.

Seems complicated work. Please give me a better way to solve it.

  • I have one timer. According to the above schedule, it has to calculate time interval between 11-June-2013 19:16 and 17-June-2013 23:59 (as Tuesday has custom period). Now start the timer with 'Resume' status.
  • After this timer elapsed, the interval is calculated between 17-June-2013 23:59 to 18-June-2013 06:00.Now Start the timer with 'Suspend' status. and so on....
Tamilmaran
  • 1,257
  • 1
  • 10
  • 21
  • If you want to do it all in a single program, then your approach is probably the best one. Although you could have a problem with elapsed time and Daylight Saving Time. You might be interested in my Waitable Timer. See http://www.devsource.com/c/a/Languages/Waitable-Timers-in-NET-CSharp/. Source code is available at http://www.mischel.com/pubs/waitabletimer.zip – Jim Mischel Jun 11 '13 at 15:52
  • But I need a timer based on the schedule. If i give a schedule like above it needs to trigger in the starting point of active time range & inactive time range. – Tamilmaran Jun 12 '13 at 06:30

1 Answers1

0

I assume that the scheduling application you show above persists that information to a file. If so, you can do the following.

First, the process that you want to execute must have some way of being told that it needs to shut down. I'll assume that it's some kind of Windows event or a flag in a file or database somewhere that it checks periodically. If you don't have this facility, then you'll have a tough time killing the task safely.

Have a small application (call it the Keeper) that reads the schedule from the file. It then checks to see if the program you're scheduling is running. If it is running and it's time to pause, then send the signal telling it to stop. Then, create a scheduled task to restart the program at the next start time. Also create a scheduled task to make the Keeper run at the next suspend time. Then the Keeper exits.

Any time you modify the schedule, you just need to run the Keeper program and it will figure out what it needs to do: suspend the program, schedule the program to run again, and schedule itself to run again at the next pause time.

There's a small amount of complexity involved in maintaining the scheduled tasks, but it's not too bad. Just have Keeper delete any scheduled task for Program and for Keeper, basically maintaining things so that there is never more than one of each.

You'll need to access the task scheduler API.

Community
  • 1
  • 1
Jim Mischel
  • 131,090
  • 20
  • 188
  • 351