September 20th 2008

Simulate a Windows Service Using ASP.NET to Run Scheduled Jobs

Back in 2005 Omar Al Zabir (Co-founder and CTO of PageFlakes) posted an article on the CodeProject web site Simulate a Windows Service using ASP.NET to run scheduled jobs that many of you have probably seen. If you liked the idea at the time but didn’t do anything with it, you may want to take another look now. In the comments, dselkirk provided an alternative that really cleans things up that Erichero then improved upon slightly and converted to C#.

The code from the comments is below. I can confirm it works. I have not modified it in any way. All credit goes to Omar, dselkirk and Erichero.

Example usage (code goes in the Aplication_Start event in Global.asax)

Scheduler.Run("test", 1, RunScheduledTasks);
public void RunScheduledTasks()
//do stuff