title: HttpClient.GetStringAsync is not executed
body: <p>The code runs in .NET Standard 2.0. I have a constructor calling a method which will call an Azure function like this:</p>
  <pre><code>public ChatViewModel(IChatService chatService)
  {
      Task.Run(async () =&gt;
      {
          if (!chatService.IsConnected)
          {
              await chatService.CreateConnection();
          }
      });
  }
  </code></pre>
  <p>The method is like this:</p>
  <pre><code>public async Task CreateConnection()
  {
     await semaphoreSlim.WaitAsync();
  
     if (httpClient == null)
     {
          httpClient = new HttpClient();
     }
  
     var result = await httpClient.GetStringAsync(uri);
  
     var info = JsonConvert.DeserializeObject&lt;Models.ConnectionInfo&gt;(result);
  
     //... some other code ...
     semaphoreSlim.Release();
  }
  </code></pre>
  <p>The code stops at</p>
  <blockquote>
  <p>await httpClient.GetStringAsync(uri)</p>
  </blockquote>
  <p>The URI is 100% valid, if I copy and paste it in the browser I get the JSON I wanted.</p>
  <p>When opening up Fiddler, no call has been made to the URI.</p>
  <p><strong>EDIT</strong>
  Source code is coming from this Github repo: <a href="https://github.com/PacktPublishing/Xamarin.Forms-Projects/tree/master/Chapter06-07/Chat/Chat" rel="nofollow noreferrer">https://github.com/PacktPublishing/Xamarin.Forms-Projects/tree/master/Chapter06-07/Chat/Chat</a></p>
  <p>And oddly enough I seem to get a call in Azure:
  <a href="https://i.stack.imgur.com/M6sC3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/M6sC3.png" alt="enter image description here" /></a></p>
  <p><strong>EDIT 2</strong>
  This code is working:</p>
  <pre><code>static void Main(string[] args)
  {
      using (var httpClient = new HttpClient())
      {
          var a = httpClient.GetStringAsync(uri).GetAwaiter().GetResult();
      }
  }
  </code></pre>
  <p>This code is not working:</p>
  <pre><code>static void Main(string[] args)
  {
      Task.Run(async() =&gt; {
          using (var httpClient = new HttpClient())
          {
              var a = await httpClient.GetStringAsync(uri);
          }
      });
  }
  </code></pre>