I was wondering what would be a simple and effective way to trigger a long lasting/running stored procedure call via the ASP.NET MVC 3 User Interface having the web UI to return immediately and the user “allowed” to close the browser and check again later.
I really would not like to create a windows service only for this, I was thinking about using the ThreadPool.QueueUserWorkItem approach, a recycle would not even be a big problem and application is not going to be under heavy load, is an internal WebUI we are making to simplify some maintenance tasks.
Has anybody tried the ThreadPool.QueueUserWorkItem approach and used application cache or similar way to persist the status of the stored procedure call like “EXECUTING” or “COMPLETED” ?
Anything that gets queued into the ThreadPool steals resources to ASP.NET request processing queues. If you plan to run many long-running tasks, then you should use a different thread/thread pool. If it’s just once in a while, then it’s surely a viable solution.
In any case, keep in mind that you cannot access application cache/session from outside a web request, so you must find another way to hold the status of the task.