views:

197

answers:

2

I am looking for a way of efficiently specifying a recurring job execution time without having to write an explicit execution time to a datastore. In other words, rather than saying 'job x next runs at 13.00pm on 11.12.08' and then having to update the execution time for the following week once the job has run, I want to be able to say 'job x runs at 13.00pm every thursday'. I need to be able to specify a recurrence range of anything from a few minutes to once per month. My guess is the shorter the recurrence period, the more difficult this becomes. Any ideas?

Note: I'm not looking for advice on the scheduling mechanism. I cannot use Windows Scheduler, Cron or create a Windows Service (I have no choice but to use a background thread in ASP.NET).

+3  A: 

I have seen cron expressions used widely for doing this, it might work well as an internal representation format.

kamal.gs
+1  A: 

I agree with kamal that Cron is probably the simplest solution to configuring a scheduler. It is very flexible - you can configure it to do just about anything (within reason).

I've used Quartz.NET for scheduling in the past. It provides a CronTrigger - see the tutorial. You could create a thread in your web app that runs the Quartz scheduler.

Andy White