I’ve a heavy operation which takes long time to be completed in my asp.net application. I don’t want to run the entire operation in one request which may result in a TimeOut error. Instead I want to invoke the operation in a separate thread and poll for the result every x seconds. How can I do this?
If the operation gets completed I need to register a script in the ajax postback to hide the loading panel and show the content. However I’m not able to register new scripts and invoke it during ajax postbacks.
Any ideas?
Option 1
In your code-behind you can launch a thread and have some class that manages the running threads. Then you can have a control in an UpdatePanel which polls for the progress every few seconds.
Option 2
Store the details of the “thing to do” in the database and have a background service continually check for work to do. It would do the work and report progress. You would have a control like in Option 1 which checks the progress and updates the UI.