DEV Community

Discussion on: Building A .NET Core 3 Scheduled Job Worker Service

Collapse
 
kaos profile image
Kai Oswald

I really like the concept of Invocables! It keeps the code clean.

For scheduling I've always used hangfire, which works really well, but things can get messy really fast since scheduling in hangfire works with anonymous method invocation

var jobId = BackgroundJob.Schedule(
    () => Console.WriteLine("Delayed!"),
    TimeSpan.FromDays(7));

Is there a way to update/cancel a scheduled task with Coravel (like in the above example where a jobId is returned?
In my side project I'm currently using hangfire, but Coravel looks a lot cleaner and I've already wondered how I can clean up these hangfire invocations.

Collapse
 
jamesmh profile image
James Hickey

Hangfire is def the defacto right now. Coravel was never built as a direct alternative, but many have pointed out that it's much easier to use.

Also, Coravel supports true async jobs, whereas Hangfire doesn't actually support true async jobs. So all that I/O in your background jobs will actually block your threads ðŸĪŠ.

See here for more

So, the answer to your question is "yes and no". There's an open issue here that I have on the todo list.

I offered a temporary/potential solution for now in that issue. Basically, you would just manage the tasks in a collection yourself. Coravel gives you some lower-level methods to start/stop any jobs you want (although, it's a workaround of sorts until there is an actual feature added 😂).