title: Awaiting a Callback method
body: <p>I'm calling a third-party API which has a method that looks like this:</p>
  
  <pre><code>myServiceClient.Discover(key, OnCompletionCallback);
  
  public bool OnCompletionCallback(string response)
  {
      // my code
  }
  </code></pre>
  
  <p>My challenge is, I have to call <code>Discover</code> because it does some work under-the-covers that I need. At the same time, I have to wait for <code>Discover</code> to complete before running my custom code. To further complicate matters, I can't just put my code in the <code>OnCompletionCallback</code> handler because I need to call the code above from a <code>Func</code> delegate. In short, I want to do this:</p>
  
  <pre><code>Func&lt;SystemTask&gt; myFunction = async () =&gt;
  {
      await myServiceClient.Discover(key);
  
      // my code
  }
  </code></pre>
  
  <p>However, I can't do this because the third-party API uses a callback approach instead of an async/await approach. </p>
  
  <p>Is there some way to make the callback approach work in an async / await world? </p>