Skip to content

dochoffiday/ScheduleMagic

Repository files navigation

ScheduleMagic

A simple ASP.NET task scheduler.

Create a Task

To create a task, simply create a class that implements IScheduledTask.

public class GenericTask : IScheduledTask
{
    public void DoWork()
    {
        // do something
    }
}

Register the Task

To initialize the task (which is usually done when the application starts), invoke the scheduler with an instance of a schedule (you can use a default schedule, or create a schedule of your own).

public class Global : System.Web.HttpApplication
{
	protected void Application_Start(object sender, EventArgs e)
	{
		Scheduler.Schedule<GenericTask>(new Daily(3, 30, "Eastern Standard Time"));
	}
}

(Optional) Create a Schedule

To create a new schedule, create a class that implements ISchedule.

public class Interval : ISchedule
{
    private long _seconds;

    public Interval(long seconds)
    {
        _seconds = seconds;
    }

    public DateTime GetUtcExpirationDate()
    {
        return DateTime.UtcNow.AddSeconds(_seconds);
    }
}

About

Simple Task Scheduler for ASP.NET

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published