Click here to Skip to main content
14,365,495 members

.NET Windows Service Scheduler

Rate this:
3.29 (10 votes)
Please Sign up or sign in to vote.
3.29 (10 votes)
5 Oct 2006CPOL
Lets you schedule your Windows service to fire at appropriate times


This program lets you schedule your Windows service to run at user configured intervals. It's inspired by this article by Andy Brummer.

The scheduler lets you schedule your Windows service code in one of the following three ways:

  1. Once a day
  2. Once a week
  3. Once a month

If you want to schedule multiple times, instantiate as many Scheduler objects you want.

It mails any exceptions to the user supplied email addresses. If the user chooses not to email, exceptions will be logged to the event log under "Service Scheduler".


Add a reference to the Scheduler.dll:

using Sathish.ServiceScheduler;
Scheduler sch = new Scheduler("MyServiceName");
MailConfiguration mailConfig = new MailConfiguration(, 
    "", "Service Down", "localhost", "MyServiceName");

//If you don't do this, all your exceptions will be logged to the event log 
//under "Service Scheduler"
sch.MailComponent = mailConfig; 

//Subscribe to the schedulerFired event.
//I used EventHandler because it was straightforward. 
//You can write your own delegate signature.
sch.SchedulerFired += new EventHandler(YourServiceMethod); 

//Schedule weekly or monthly or daily
sch.ScheduleWeekly(DayOfWeek.Friday, "3:00 AM");

//sch.ScheduleMonthly(4, "6:20 PM"); //4 is 4th day of the month.
//sch.ScheduleDaily("4:00 AM");

The program checks if your mail infrastructure is in place. If not, it throws an exception.

And yes, it also takes care of 30/31/28/29 day months. So if you said...

sch.ScheduleMonthly(31, "4:00 AM") 

... and the month had only 30 days, the program adjusts the difference and the scheduler fires on the last day (in this case 30th) of the month.

I haven't had the time to test it thoroughly. I will do it in the coming days and update any revisions. If any of you find anything amiss, please let me know at

If you make enhancements, do send me a copy/link.


  • 5th October, 2006: Initial post


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


About the Author

India India
No Biography provided

Comments and Discussions

Questionerror when scheduling monthly Pin
Member 107976635-Feb-19 0:30
memberMember 107976635-Feb-19 0:30 
QuestionTwo dates Pin
Nelson634013-Jan-17 11:10
memberNelson634013-Jan-17 11:10 
GeneralMy vote of 4 Pin
sridevibathula11-Mar-12 21:00
membersridevibathula11-Mar-12 21:00 
QuestionCan anybody help me? Pin
kalika_brandoa15-Nov-07 8:05
memberkalika_brandoa15-Nov-07 8:05 
AnswerRe: Can anybody help me? Pin
sashisme15-Nov-07 8:17
membersashisme15-Nov-07 8:17 
GeneralRe: Can anybody help me? Pin
kalika_brandoa16-Nov-07 0:03
memberkalika_brandoa16-Nov-07 0:03 
GeneralRe: Can anybody help me? Pin
kalika_brandoa16-Nov-07 0:41
memberkalika_brandoa16-Nov-07 0:41 
GeneralRe: Can anybody help me? Pin
sridevibathula11-Mar-12 22:37
membersridevibathula11-Mar-12 22:37 
GeneralRe: Can anybody help me? Pin
getvinay198819-Mar-14 20:59
membergetvinay198819-Mar-14 20:59 
Generalpossible limitation Pin
fidelitylife3-Jul-07 19:13
memberfidelitylife3-Jul-07 19:13 
QuestionHourly/other updates Pin
Dan B Atkinson11-Apr-07 0:40
memberDan B Atkinson11-Apr-07 0:40 
GeneralGood stuff Pin
Wirelessnz17-Oct-06 21:59
memberWirelessnz17-Oct-06 21:59 
GeneralRe: Good stuff Pin
sashisme8-Oct-06 20:05
membersashisme8-Oct-06 20:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Posted 5 Oct 2006


35 bookmarked