title: C# - return boolean from Async method
body: <p>I have Async method which is called inside button_click. Async method runs 3 different void's and each void has It's own error handling. If any error inside those 3 methods occure I want to show that particular error message and stop code inside button_click - which also runs more non-async method and has It's error handling. What I did was this (example):</p>
  
  <pre><code>private void button1_Click(object sender, EventArgs e)
  {
      try
      {
         //calling non-async method, if It fails It should show error 
         //inside this event
         Method1();
  
          if (TestAsync().IsCanceled)
          {
              return;
          }
  
          MessageBox.Show("Test");
      }
      catch (Exception)
      {
          MessageBox.Show("Async method failed and this message should not be diplayed!");
          throw;
      }
  }
  
  public async Task&lt;bool&gt; TestAsync()
  {
      bool completed = await Task.Run(() =&gt; MethodToComplete());
      return completed;
  }
  
  private bool MethodToComplete()
  {
      try
      {
          //renaming file, but intentionally fail for test purpose
          Directory.Move("fail_this_method", "fail");
          return true;
      }
      catch (Exception ex)
      {
          MessageBox.Show("Error: " + ex.Message);
          return true;
          throw;
      }
  }
  </code></pre>
  
  <p>The result of this example is - It does display error message from void which is called asynchronously and doesn't show error message from button_click. But It also displays <strong>MessageBox.Show("Test");</strong> which shouldn't, code in button_click should stop immidiately if Async fails.</p>
  
  <p>I hope I was clear enough, any help kindly appreaciated !</p>