This is a general "best practices" question on the pros and cons of multiple asynchronous calls that need 开发者_如何学Goto be made in rapid succession.
In my specific instance I need to make 4 asynchronous calls from a silverlight application. As it stands, we're simply displaying an indeterminate progress spinner until, in the callback, the spinner is hidden.
Now, the hypothetical I put forth. Is it better to make the 4 multiple calls in an "onion" fashion? Or is it better to make them one after another? They're independent of each other in that the result of Call 1 does not affect 2, 3 or 4 and so on.
Scenario A:
Call 1 made ->
Call 2 made in Call 1 callback ->
Call 3 made in Call 2 callback ->
Call 4 made in Call 3 callback
Scenario B:
Call 1 made
Call 2 made
Call 3 made
Call 4 made
If the result of the previous calls have no effect on the subsequent ones than why wait? It's going to take longer if you do them in series rather than in parallel.
精彩评论