This project is read-only.

Using the code

Working with the scheduled task library is centered around 3 main classes / interfaces, the ScheduledTaskRunner, ScheduledTask, and the IExecution. You implement the IExecution interface on a class will contain the work you want to have scheduled. A ScheduledTask in turn has an IExecution attached to it, that is run by the instance of the ScheduledTaskRunner on the interval you specify. Note that currently the smallest scheduling interval is 60 seconds.

Scheduling a Task

Scheduling is easy. Consider this simple class that generates a random number:

public class RandomNumberExecution : IExecution
        #region IExecution Members

        public IExecutionResult Execute(IExecutionContext executionContext)
            return new ExecutionResult(new Random().Next().ToString());


We want to generate a new number every minute. This is how we would schedule that work to be done:

var scheduler = ScheduledTaskRunner.Instance;
scheduler.ScheduleTask("randomnew", new TimeSpan(0, 1, 0), new RandomNumberExecution());

Rough around the edges

This is by no means a finished product yet. There are concepts in the code (ExecutionContext in particular) that are incomplete or don't serve a real use yet. This release serves as an initial proof of concept and refinement / polish will come with time.

Last edited Jan 29, 2011 at 7:48 PM by clonked, version 1


No comments yet.