title: C# DownloadSync event not fired
body: <p>Experimenting with WebClient.DownloadFileAsync:</p>
  
  <pre><code>public void DownloadFile(string fileUrl, string localFile)
  {
      using (WebClient client = new WebClient())
      {
          downloadingFile = true;
          client.DownloadFileCompleted += client_DownloadFileCompleted;
          client.DownloadFileAsync(new Uri(fileUrl), localFile);
  
          while (downloadingFile) { };
      }
  }
  
  private void client_DownloadFileCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
  {
      downloadingFile = false;
  }
  </code></pre>
  
  <p>Problem is that the DownloadFileCompleted event is never fired, so I never set downloadingFile = false => the while loop never finishes.</p>
  
  <p>Any ideas for what is going wrong?</p>
  
  <p>Thanks!</p>