title: Wrapping a Task to return a value
body: <p>I feel like there is a better way to do the following and looking for other opinions.  </p>
  
  <p>Essentially, I am trying to utilize the async/await pattern but need to return a bool value from method to indicate what happened in the method which is causing me to wrap the Task with Task so this can be accomplished.  My spidey-sense is telling me something is wrong with my implementation.</p>
  
  <p>In the below example "LongRunningTask" is something I don't have control over because it is a library method that returns a Task, so something I can't change.  The remainder of the flow logic could be changed.  Obviously, this is just a fictional representation of my real-issue but meant to demonstrate the issue, so don't get caught-up in the hard-coded "GetData", etc...</p>
  
  <p>Take a look and let me know of other options.</p>
  
  <pre><code>void Main()
  {
      StartApplication();
  }
  
  private async void StartApplication()
  {
      // This is a just fictional example passing hard-coded GetData
      var didExecuteLongRunningTask = await ProcessStuff("GetData");
  
      if (didExecuteLongRunningTask)
      {
          Console.WriteLine("Long running task was executed");
      }
      else {
          Console.WriteLine("Long running task was NOT executed");
      }
  }
  
  // Define other methods and classes here
  private async Task&lt;bool&gt; ProcessStuff(string command)
  {
      if (command == "GetData")
      {
          await LongRunningTask();
          return await Task&lt;bool&gt;.Factory.StartNew(() =&gt; true);
      }
      else
      {
          return await Task&lt;bool&gt;.Factory.StartNew(() =&gt; false);
      }
  }
  
  private Task LongRunningTask()
  {
      return Task.Delay(2000);
  }
  </code></pre>