Click here to Skip to main content
15,891,372 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi,
Problem Definition: To create a scheduler that will run a process based on the scheduled time. (I am not supposed to use windows task scheduler)
I have an XML that contains scheduling data.
Process A will run at Time t1.
Process B will run at Time t2.

My Approach:
I am coming up with a Windows Service for this scheduler in MFC. It will read the XML at start up. Run the process at that particular time.

Need inputs for:
1. I want to make sure if my approach is fine to build this scheduler.
2. At the implementation level, do I need to create a thread for Process A to run at time t1?
3. In case I change the scheduling time in XML, can i somehow trigger this windows service to read the XML again without system restart?

Please provide your inputs/concerns regarding the design/implementation or point me to the links that can help me with this.

Regards
Posted
Updated 4-Jun-12 22:39pm
v4

1 solution

1. Sure... why not?
2. Only if you have to wait for the process to complete, otherwise, it doesn't have to be on its own thread (spawn an independent process and just let it be).
3. You can have a reload option through the command prompt, a lot of Linux processes simply do this by turning off the service then turning it back on (simple yet effective), or you can get a bit fancier and have a user interface, that way your service doesn't have to get restarted.
 
Share this answer
 
Comments
RedUnited 6-Jun-12 2:14am    
Thank you for the inputs.
I went through few of the topics in Code Project regarding Scheduler design, all of them are .net related projects.
Following is one sample data from XML I will fetch:
Name: Task1
Exe: task1.exe
Daily: Time:1000(hrs) (OR)
Weekly: Time:1010(hrs) Mon:Yes/No Tue:Yes/No and so on... (OR)
Monthly: Time:1020(hrs) DayOfMonth:20
Duration: 2(min)

Based on the frequency of run, i will need respective details:
If Daily: int Time;

If Weekly: int Time;
int Day[7]; \\Day 0 to 6; 0-Sun, 1-Mon, 2-Tue and so on. Whichever checked will be 1 else 0

If Monthly int Time;
int DayOfMonth;

1. Currently, I am planning to use Struct, but I am finding it hard to manage things. Please suggest me a way to manage all the data.
2. How do I trigger the windows service to run "Task1.exe" at that particular time (keep in mind task will be run daily or Weekly or Monthly)?
Ex: I schedule Task1 Daily at 0400hrs. Present time is 1200hrs.I can take the difference time and put to sleep(). But in case of Monthly, it will be hard to find difference and the value will go beyond the limits in msec.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900