Currently there are many different ways to implement recurrent tasks on Microsoft platform with the .NET Framework. The following table describes pro and cons for some of them:

 

Pro

Cons

Task Scheduler
  • Propose large choice of scheduling
  • Aware of daylight saving time
  • Include execution history
  • Force implementation of recurrent tasks in dedicated components
  • Increase deployment complexity
  • Schedule alteration made through platform invokes
SQL Job
  • Propose large choice of scheduling
  • Aware of daylight saving time
  • Include execution history
  • Force implementation of recurrent tasks in dedicated components
  • Increase deployment complexity
  • Schedule alteration made through SQL Server API
.NET Framework Timers
  • Integrated recurrent tasks
  • Decrease deployment complexity
  • Native support for schedule alteration

 

  • Propose only one scheduling
  • Agnostic of daylight saving time
  • No execution history

As shown above, implementing recurrent tasks integrated within your solution is not straightforward. Actually it would be nice if the .NET Framework timers could offer a large choice of scheduling with support to the daylight saving time.

We can easily achieve this by combining a System.Threading.Timer with the Recurrence domain model where the Change method of the System.Threading.Timer is invoked after each occurrence according to the schedule of the next occurrence.

You will find here after a description of the ScheduledTimer.

 image16

Property Description
Timer

The underlying System.Threading.Timer

Action

The scheduled action invoked by the underlying timer

Recurrence

The recurrence of the scheduled action

Occurrences

The number of scheduled occurrences or zero (0) for infinite schedule

NextOccurrence The next occurrence (one-based) or zero (0) in case of infinite schedule
NextSchedule The schedule of the next occurrence

Last edited Jan 10, 2012 at 10:25 AM by schabannes, version 10

Comments

No comments yet.