title: Download multiple files async and wait for all of them to finish before executing the rest of the code
body: <p>I am trying to download multiple files from the internet and await for all of them to finish.  This is a C# console application that I am running, so no progress bar event handler should be necessary.  However it currently just continues to execute code even though all files have not been downloaded. </p>
  
  <ul>
  <li>1.Downloading all files!</li>
  <li>2.Finished Download File A</li>
  <li>3.Finished Downloading all files!</li>
  <li>4.Finished Downloading File B</li>
  <li>5.Finished Downloading File C</li>
  </ul>
  
  <p>How would you await till all async download files are finished.</p>
  
  <pre><code> private void DownloadMultipleFiles(List&lt;DocumentObject&gt; doclist)
      {
          foreach(var value in doclist){
              try
              {
                  using (WebClient webClient = new WebClient())
                  {
                      string downloadToDirectory = @Resources.defaultDirectory + value.docName;
                      webClient.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;
                      webClient.DownloadFileCompleted += client_DownloadFileCompleted;
                      webClient.DownloadFileAsync(new Uri(value.docUrl), @downloadToDirectory);
  
                      //Add them to the local
                      Context.listOfLocalDirectories.Add(downloadToDirectory);
                  }         
              }
              catch (Exception)
              {
                  Errors.printError("Failed to download File: " + value.docName);
              }
          }
      }
  </code></pre>