title: Upload Files in Parallel with WebClient
body: <p>I need to use WebClient in a project to split a file into multiple parts and upload them in parallel. So far, I'm able to upload the parts one at a time, but am unsure as to how to upload them in parallel.</p>
  <p>I have an UploadPart method which looks like this:</p>
  <pre><code>private async Task&lt;PartETag&gt; UploadPart(string filePath, string preSignedUrl, int partNumber)
  {
      WebClient wc = new();
      wc.UploadProgressChanged += WebClientUploadProgressChanged;
      wc.UploadFileCompleted += WebClientUploadCompleted;
      _ = await wc.UploadFileTaskAsync(new Uri(preSignedUrl), &quot;PUT&quot;, filePath);
  
      // Obtain the WebHeaderCollection instance containing the header name/value pair from the response.
      WebHeaderCollection myWebHeaderCollection = wc.ResponseHeaders;
      string formattedETag = myWebHeaderCollection.GetValues(&quot;ETag&quot;).FirstOrDefault().Replace(@&quot;&quot;&quot;&quot;, &quot;&quot;);
      PartETag partETag = new(partNumber, formattedETag);
  
      return partETag;
  }
  </code></pre>
  <p>Its called inside a foreach loop:</p>
  <pre><code>foreach (var part in parts)
  {
      var partETag = await UploadPart(part.FilePath, part.PresignedUrl, part.Number);
      partETags.Add(partETag);
  }
  </code></pre>
  <p>How can I modify this so that I upload parts in parallel (up to a max of 10 parts at once) while still returning the PartETag values in the response header?</p>