Search code examples
c#model-view-controllerhangfire

Can Hangfire Handle Changes to Scheduled Tasks Without Redeployment


I have been playing around with Hangfire in a Microsoft MVC application. I have gotten it to compile and schedule fire-and-forget tasks, but I am surprised that I cannot add/remove jobs while the program is running. Is it true that Hangfire cannot dynamically schedule tasks during runtime? Is there a well-known framework that allows one to schedule tasks even after the application has been compiled or deployed without having to change the C# code every time I want to add tasks?

I have also researched Quartz.NET, and it seems to have the same issue.

EDIT:

Windows Task Scheduler can allow tasks to be scheduled with a GUI, and UNIX's cron can have tasks added or removed by editing a file, but I'm looking for some sort of application running on Windows that would allow the user to add or remove tasks after the application has been deployed. I do not want to re-compile the application every time I want to add or remove tasks.


Solution

  • As asked, the question seems to rest on a misunderstanding of the meaning of "dynamic...during runtime". The answer is "yes," it can change tasks without redeployment (but that doesn't appear to be what you're really looking for).

    Hangfire will add a dashboard UI to your application if you configure it to do so, but it is not an end-to-end task management application itself. It is designed to give your application the ability to schedule work, and have that work completed in a very disconnected way from the point of invocation--it may not even be completed on the same machine.

    It is limited to invoking .NET code, but by definition this fulfills your stated requirement to "dynamically schedule tasks during runtime." This can be done in response to any event within your application that you like. Tasks can also be removed, updated and canceled.

    (Post-edit) You're correct: any scheduling UI or deserialization of task-file format you'll have to write yourself. If you are looking for a tool that gives you a UI and/or task-file OOTB, you may need to move up to a commercial product like JAMS. (Disclaimer: this may not even itself have the capabilities you require--I don't have direct experience with the product but folks I've worked with have mentioned it in a positive light).