title: How to execute multiple async calls in parallel?
body: <p>I have a number of commands that make calls to a soap web service (Betfair API). All are of the classic asynchronous programming model type ...</p>
  
  <pre><code>public void DoXXX( &lt;input parameters ...&gt; )
  {
      XXXRequest Request = new XXXRequest();
      // populate Request from input parameters ...
      BetfairService.BeginXXX( Request, XXXCallback, State );
  }
  
  private void XXXCallback(IAsyncResult Result)
  {
      XXXResponse Response = BetfairService.EndXXX(Result);
      if (Response.ErrorCode == XXXErrorCode.OK)
          // store data from Response
      else
          // deal with error
  }
  </code></pre>
  
  <p>I want to execute a specified set of commands, and then do some calculations using the combined returned data values, once all of commands are completed.</p>
  
  <p>I'm able to do this as a sequence, by making a queue of commands and having each callback method trigger the next command in the queue once it's complete, with the calculation as the last item in the queue. This is relatively slow however.</p>
  
  <p>My ideal solution would be to have all of these commands running in parallel and then to have the calculation triggered once all of the commands are completed. I've tried looking at Task.Factory.FromAsync(), but all of the examples I can find only include direct calls to BeginXXX / EndXXX, not doing anything with the response.</p>
  
  <p>Does anyone have any pointers for a suitable solution to this problem?</p>