title: Would making DB calls async inside a Parallel.ForEach loop improve performance?
body: <p>When using Parallel.ForEach, would converting any DB or Api calls to async methods improve performance?</p>
  
  <p>A bit of background, I currently have a console application that sequentially loops through a bunch of files and for each one calls an API and makes some DB calls. The main logic looks like this:</p>
  
  <pre><code>foreach (file in files)
  {
      ReadTheFileAndComputeAFewThings(file);
      CallAWebService(file);
      MakeAFewDbCalls(file);
  }
  </code></pre>
  
  <p>Currently all of the DB and web service calls are synchronous.</p>
  
  <p>Changing the loop to use <code>Parallel.ForEach</code> has given me a massive performance increase, just as you would expect.</p>
  
  <p>I am wondering if I kept the <code>Parallel.ForEach</code> call there, and inside the loop, change all of the webservice calls to be async (eg, <code>HttpClient.SendAsync</code>) and DB calls to be async (using Dapper, <code>db.ExecuteAsync()</code>) - would that increase performance of the application by allowing it to re-use threads? Or would it effectively do nothing as <code>Parallel.ForEach</code> is taking care of the thread allocation anyway?</p>