title: Calling async method synchronously
body: <p>I have an <code>async</code> method:</p>
  <pre><code>public async Task&lt;string&gt; GenerateCodeAsync()
  {
      string code = await GenerateCodeService.GenerateCodeAsync();
      return code;
  }
  </code></pre>
  <p>I need to call this method from a synchronous method.</p>
  <p>How can I do this without having to duplicate the <code>GenerateCodeAsync</code> method in order for this to work synchronously?</p>
  <p><strong>Update</strong></p>
  <p>Yet no reasonable solution found.</p>
  <p>However, I see that <code>HttpClient</code> already implements this <em>pattern</em></p>
  <pre><code>using (HttpClient client = new HttpClient())
  {
      // async
      HttpResponseMessage responseAsync = await client.GetAsync(url);
  
      // sync
      HttpResponseMessage responseSync = client.GetAsync(url).Result;
  }
  </code></pre>