Currently, I use Hangfire to run background processing regularly.
RecurringJob's periodic execution is at least one minute apart.
RecurringJob.AddOrUpdate(
( ) = > Console.WriteLine("Recurring!"),
Cron.Minuty);
I'd like to move it in seconds (for example, every 10 seconds). Is there a good way?
The rich management console is attractive, so I would like to use Hangfire as it is if possible, but if there is a service that can be used in a similar way, I don't mind.
Thank you for your cooperation.
asp.net
Quartz Enterprise Scheduler.NET
https://www.quartz-scheduler.net/
Quartz.NET 3.0 is currently in Alpha version, but it seems that there will be Core compatible and periodic execution in seconds.(I have never tried it.)
A sample tBuild a trigger for a specific moment in time, then repeating every second time times の is helpful.
https://www.quartz-scheduler.net/documentation/quartz-2.x/tutorial/simpletriggers.html
trigger=TriggerBuilder.Create()
.WithIdentity("trigger3", "group1")
.StartAt(myTimeToStartFiring) // if a start time is not given (if this line were selected), "now" is imported
.WithSimpleSchedule(x=>x
.WithIntervalInSeconds (10)
.WithRepeatCount(10)//note that 10 repeats will give a total of 11 fires
.ForJob(myJob)//identify job with handle to it JobDetail itself
.Build();
I'm sorry.Although there is no environment, Hangfire
seems to allow NCronTab
to specify in seconds.(added support for seconds in NCronTab expressions)
If you specify it in six formats, you can specify seconds on the far left, so you might want to do the following:(NCronTab)
RecurringJob.AddOrUpdate(
( ) = > Console.WriteLine("Recurring!"),
"*/10 * * * * *");
© 2024 OneMinuteCode. All rights reserved.