Skip to content

cashwu/Cashwu.AspNet.Scheduled

Repository files navigation

Asp.Net scheduled

actions


Nuget


Implement your scheduled task from IScheduledTask

  • Schedule is cron schedule, could referrence crontab
    • minimum 1 minute (* * * * *)
  • IsLazy is application started run once immediately
  • ExecuteAsync is your scheduled job
public class YourTask : IScheduledTask
{
    public string Schedule { get; }

    public bool IsLazy { get; }
    
    public Task ExecuteAsync(CancellationToken cancellationToken)
    {
        throw new NotImplementedException();
    }
}

Global.asax.cs

  • Application_Start method add ApplicationScheduler.Start() in last line
    • first parameter is scheduler task implement assembly name
    • second parameter is error handler event
protected void Application_Start()
{
    ...

    ApplicationScheduled.Start("assembly name", (sender, args) =>
    {
        Console.WriteLine(args.Exception);
    });
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages