Reputation: 834
I working on Asp.net core project and need on request on one controllers action trigger some method and don't wait for it to finish but respond to caller immediately. How can I accomplish it?
Upvotes: 0
Views: 1188
Reputation: 5312
You can certainly use a Task for this. However, this isn't a good idea because if ASP.NET recycles, your work will disappear.
Task.Run(() => FireAndForgetMethod());
A more robust and safe choice is to use something like Hangfire.io which relies on reliable storage.
BackgroundJob.Enqueue(() => FireAndForgetMethod());
Upvotes: 1