Windows Service and time check question

  • Thread starter Thread starter Brian Henry
  • Start date Start date
B

Brian Henry

I want to make a schedule of events to occur in a windows service (kinda
like a scheduler) so the user can specify through an external interface to
do a task at a certain time... like this

8pm - import data
2am - process data

but how exactly would you check for those times in order to start the
processing? is there another way besides using a time to check every second
or is that the only way around it? thanks!
 
Hi Brian,

I think we do need to check the data to know if a program needs to be
started. We know that the OS is running based on one real-time clock which
help to do the thread schedule. In the low level the OS utilize the clock
IRQ to do the job. On the high level, i.e. the our program running on the
OS, OS provides the similar machanism, i.e. the timer function, in .net
framework the Timer is the wrap class for the OS provided timer.

I think a normal and recommend approach is to check the scheduled programs
trigger time periodically e.g. every 1 minutes. Once we find that there
will be one program will be running in one minutes(e.g. after 30 seconds,
the program need to be started), then we can start another timer and set
its Interval to be 30000(30 seconds) and handle its Elapsed event, thus, 30
seconds later, the event handler will be called to start the program.

Here is a C# program, you may try to take a look.
http://www.thecodeproject.com/csharp/scheduler.asp

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Hi Brian,

I am glad that my suggestion will help you.

Cheers!

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Back
Top