I have a .NET 4.0 ASPX page that is performing a series of semi complex calculations. These calculations could take some time and are separated into a number of methods on the page. The UI on the ASPX page contains Page Properties which retrieve the values assigned as a result of these calculations.
I would like to know the recommended JS/Ajax/jQuery approach for doing the calculations after the initial page load with ASP.NET and having some kind of loading effect running whilst the calculations are being processed.
I would like the code to be as lightweight as possible in order to achieve this. Pointers and advice on best practice greatly appreciated.
How long do these calculations/processes take? Does the user need to wait for them to finish, or can the user go do other things on the site while waiting?
Perhaps this isn't what you're looking for, but an alternative approach would be to run the calculations in a separate thread (or even separate application) on the server. You'd present the user with a message saying that their calculations have been queued for processing and will begin shortly.
The user can check back to see when it's done, or even have some kind of notification system on the sire (picture the little red "you have a new message" thing on Facebook, or some similar functionality) which tells them when it's done and provides a link for the user to go see the results. The notifier could easily perform some background polling via AJAX to check for results every few moments.
If scaling is going to be a concern for this application, you may want to look into an approach like this. "Online" processing in response to page events is going to drag performance as the system scales, especially during heavy load times. "Offline" processing by means of queuing up processes in the background will allow you to monitor the queue for heavy load, offload those processes to different hardware, add new functionality without killing user experience or dealing with page timeouts, etc.