Wednesday, March 21, 2012

Parallel Asynchronous Calls to Webservice

I'm working on a dashboard / portal system that makes use of ajax to populate the contents of the dashboard objects (dashlets, or portlets). In my javascript page load event handler, I make an asynchronous call to a web service, specifically a webmethod which returns the HTML/XML necessary to render the contents of the dashlet.

What I have is effectively the following (in pseudocode for simplicity):

on page load {

dashlet1 = service.renderFunction(dashletId1, ... );
dashlet2 = service.renderFunction(dashletId2, ... );
dashlet3 = service.renderFunction(dashletId3, ... );



However, while the page does render in an asynchronous fashion, these calls are made in sequence, so the dashlets are populated in sequence, rather than in parallel.

Is there a way to have these calls made concurrently, such that each dashlet isn't effectively waiting on the previous dashlet to have been rendered before making its own asynchronous call to the webservice? Will I have to resort to threading?

Thanks in advance for any guidance.

The problem is that browsers will only fire off two asynchronous calls at any given time. There is a good article written by the PageFlakes guy on CodeProject that detailed this issue and good design for asynchronous client-side calls:

Hope this helps!

That's great to know - I'll read up on this article.

Thanks for the link!

have you ever been able to find a solutions for this issue? I'm facing same problem, and the artcile did not seem to help, I have only two requests, and still the first request blocks the second request completly.


I worked around it using the CNAME hack. See more here:

There is no "solution" to the problem, it's an inherent limitation of current gen browsers. It's strange that you have two requests and one is being blocked. Are you sure there isn't a third call in progress?

No comments:

Post a Comment