简体   繁体   中英

Fire Cron job automatically when application run .Net core 6

I have created a cron job in an API controller in .NET Core 6 as follows:

[HttpGet]
[Route("api/RunMyJob")]
public void RunMyJob()
{
    RecurringJob.AddOrUpdate(() => jobmethod(), Cron.DayInterval(5));
}

[NonAction]
public async Task jobmethod()
{
    // ........
}

I want to fire this job automatically when the project is run, without calling the API in the browser.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM