Closed iAmarokk closed 1 year ago
If you're asking if a trigger can enqueue a job in hangfire then most certainly yes. If you're asking if you can do work in the background invoked by a trigger, without using hangfire then that is also a yes with some caveats. Can you clarify your question?
Both options are interesting. My case is the following - there is a task on audit and it can be executed in the background, whether it will be executed or not is not interesting.
As mentioned, that is perfectly possible with this library. Just keep in mind that whatever you execute in the background should be considered outside the scope of the request that caused the trigger to fire. So do not rely on services from DI as the request might be finished and those services might get disposed at any moment.
How to run background tasks is outside the scope of this project. I would recommend using Hangfire or a hosted service, however if simply _ = Task.Run(...)
is sufficient for your use case then by all means.
Hi all, Can the trigger work as an Fire-and-forget tasks in Hangfire ?