fluentscheduler asp.net example

Example: fluentscheduler asp.net example

public class Demo : Registry{    public Demo()    {        // Schedule an IJob to run at an interval        // Perform scheduled tasks every two seconds immediately. (Specify a time interval to run, according to your needs, can be seconds, minutes, hours, days, months, years, etc.)        Schedule<MyJob>().ToRunNow().AndEvery(2).Seconds();         // Schedule an IJob to run once, delayed by a specific time interval        // Delay the execution of a scheduled task at a specified interval. (Of course, this interval can still be seconds, minutes, hours, days, months, years, etc.)        Schedule<MyJob>().ToRunOnceIn(5).Seconds();         // Schedule a simple job to run at a specific time        // Perform scheduled tasks at a specified time (most commonly. This is performed every day at 1:10 pm)        Schedule(() => Trace.WriteLine("It's 1:10 PM now.")).ToRunEvery(1).Days().At(13, 10);        Schedule(() => {            // Do what you want to do.            Trace.WriteLine("It's 1:10 PM now.");        }).ToRunEvery(1).Days().At(13, 10);        // Schedule a more complex action to run immediately and on an monthly interval        // Immediately execute a scheduled task on Monday, 3:00 pm (you can see the time of this more complicated point, it means it can do it too!)        Schedule<MyComplexJob>().ToRunNow().AndEvery(1).Months().OnTheFirst(DayOfWeek.Monday).At(3, 0);        // Schedule multiple jobs to be run in a single schedule        // Perform two (multiple) tasks in the same plan        Schedule<MyJob>().AndThen<MyOtherJob>().ToRunNow().AndEvery(5).Minutes();    }}public class MyJob : IJob{    void IJob.Execute()    {        Trace.WriteLine("The time is now:" +DateTime.Now);    }}public class MyOtherJob : IJob{    void IJob.Execute()    {        Trace.WriteLine("This is another Job, now the time is:" + DateTime.Now);    }}public class MyComplexJob : IJob{    void IJob.Execute()    {        Trace.WriteLine("This is a more complicated job, now the time is:" + DateTime.Now);    }}

Tags:

Misc Example