I am using EF6, MVC 5 in VS 2013.I have a long running task which is causing timeout errors and so I want to set it running as a separate background task and return immediately to the web controller. The background task will report progress to an SQL server database. What I need, essentially, is fire and forget functionality. There appear to be a number of options:
async
- this does not seem to be a safe optionOption 3 would be preferred as it keeps all the code in one solution. Please could you comment on the pros and cons of each and point, if possible, to worked examples of number 3.
HostingEnvironment.QueueBackgroundWorkItem is a valid solution, but keep in mind that the long running process may be interrupted, for example if application pool recycles.
A better option would be to run it in a scheduled task, for example using Quartz.NET.