Scott Furr

Scott Furr

  • NA
  • 15
  • 0

Timer/Scheduler as a Windows Service in C#

Oct 27 2008 11:01 AM

Hello all,

This is my first post and I have to admit that I am a newbie when it comes to programming in C#.  With that being said, please forgive any cluelessness on my part ;)

Let me first state what I am trying to accomplish and then I'll ask my question.  I'm trying to create a windows service that will run an event at a scheduled time, similar to the windows task scheduler (which I don't want to use). For example; I want the service to launch notepad every Wednesday at 4PM.

Now for the question. Would this better better suited for a Timer or running a loop that will check the DateTime every minute and compare it to the scheduled time?  I would think running a loop like this would eventually cause an unnecessary processor load, but I'm not completely sure how C# manages memory.

FYI...  In it's end state, I would like an administrator to be able to change the scheduled time using a separate form or ASP page, so I wouldn't want the code to call a static time like Wednesday at 4PM where a timer is just set with an interval of a week.  I'd like the code to be open to the possibility that the admin would want the task to run on multiple days of the week.  This is why I'm leaning more toward using a loop that will check DateTime, but I'm leaving it to the experts to guide me :)

Thanks in advance!

Scriptd


Answers (6)