Best way to run scheduled tasks

Niels Bosma picture Niels Bosma · Feb 12, 2009 · Viewed 200.8k times · Source

Today we have built a console application for running the scheduled tasks for our ASP.NET website. But I think this approach is a bit error prone and difficult to maintain. How do you execute your scheduled task (in an windows/IIS/ASP.NET environment)

Update:

Examples of tasks:

  • Sending email from an email-queue in the database
  • Removing outdated objects from the database
  • Retrieving stats from Google AdWords and fill a table in the database.

Answer

BC. picture BC. · Feb 12, 2009

This technique by Jeff Atwood for Stackoverflow is the simplest method I've come across. It relies on the "cache item removed" callback mechanism build into ASP.NET's cache system

Update: Stackoverflow has outgrown this method. It only works while the website is running but it's a very simple technique that is useful for many people.

Also check out Quartz.NET