title: Wait on Class Method to be finished C#
body: <p>I need to Download a File from a Https Source. 
  I'll do this asynchron like this (works so far):</p>
  
  <pre><code>void doChecksbeforDownload(){
  //Do some Checks
     DownloadFileAsync();
  
  }
  
  void DownloadFileAsync(){
       ...
       ... 
       this.client.UploadStringCompleted += new UploadStringCompletedEventHandler(client_UploadStringCompleted);
       this.client.Headers["Content-Type"] = "application/x-www-form-urlencoded";
       this.client.UploadStringAsync(new Uri(url), "POST", PostParameter);
       ...
       ...
  }
  </code></pre>
  
  <p>and call the client_UploadStringCompleted() Method when finished:</p>
  
  <pre><code>void client_UploadStringCompleted(object sender, UploadStringCompletedEventArgs e)
      {
         //Do Check here
      }
  </code></pre>
  
  <p>So far so good. Now I put all this in a class "Functions" and call the Method like this:</p>
  
  <pre><code> Functions f = new Functions();
   f.doChecksbeforeDownload();
  </code></pre>
  
  <p>I want doChecksbeforeDownload() to wait until the clientUloadStringCompleted is FINISHED. </p>
  
  <p>How do I do I tell doChecksbeforeDownload to wait until the the Async call in DownloadFilesAsync is done and ready.</p>
  
  <ol>
  <li>Call doChecksbeforeDownload()</li>
  <li>ChecksbeforeDownload()->DownloadFileAsync()</li>
  <li>ChecksbeforeDownload()->Waits.......</li>
  <li>DownloadFileAsync() -> Completet &amp; Ready</li>
  <li>ChecksbeforeDownload()->returns FOO to Main Class </li>
  </ol>
  
  <p>Are there any best practices / examples to achieve this? I stuck in this point.</p>
  
  <p>Thanks in advance</p>
  
  <p>Hannes</p>