Reputation: 1555
I'm developing a web application based on ASP.NET MVC.
There are a large database. Users can search in this database using custom filters (html-form with options). After users submit the form and wait a result. It's very slow operation. But it's a not question of database optimisation or query optimisation.
So, there is slow operation. I want to run this operation and get it state from time to time without a page realoding.
I see it like:
Questions: 1. How can I run operation on the server that will be processed outside a http request? 2. How can I get state of this operation?
Upvotes: 2
Views: 395
Reputation: 1038850
How can I run operation on the server that will be processed outside a http request
You could run it in a background thread. Either spawn one manually or if you are using .NET 4.0 use TPL.
How can I get state of this operation?
Once started the operation should be assigned an unique ID and returned immediately to the client. Then when the operation progresses in the background thread it could update its progress using the ID. For example you could use the Application state to store this progress. The the client will poll the server at regular intervals to fetch the progress.
Upvotes: 3