Saturday, May 8, 2010

Executing lengthy processes at Server –Side

There are situations when certain tasks require the server to take time in responding, not because of the size of data, but because preparing that data takes time.
Under these circumstances, one could use a AJAX based approach to notify the user of the progress, and auto-load it, once the data is ready.
The following steps need to be performed
  1. Make an asynchronous call to the server with the required parameters
  2. The server will respond back with a notification, and a couple of call-back functions, which holds a URL to check the progress of this particular task.
    1. CheckProgress()
    2. GetData()
    3. Wrap the CheckProgress() call-back function is a time-interval loop, and make further asynchronous requests to check the progress.
  3. The Server will respond with the percentage of work complete.
  4. Once the Server says, it’s complete, i.e. 100% completion, clear the time-interval loop.
  5. Make another call to the server, using the GetData() call-back function.
  6. This method will return the data, augmented with a function, which holds the controls to load this data at client-side.

No comments:

Post a Comment