Introduction
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:
- Once a day
- Once a week
- 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".
Usage
Add a reference to the Scheduler.dll:
using Sathish.ServiceScheduler;
Scheduler sch = new Scheduler("MyServiceName");
MailConfiguration mailConfig = new MailConfiguration(yourmail@gmail.com,
"admin@yourcompany.com", "Service Down", "localhost", "MyServiceName");
sch.MailComponent = mailConfig;
sch.SchedulerFired += new EventHandler(YourServiceMethod);
sch.ScheduleWeekly(DayOfWeek.Friday, "3: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 mailsash@gmail.com.
If you make enhancements, do send me a copy/link.
History
- 5th October, 2006: Initial post