HttpClient causes high cpu usage after a request (Xamarin)

时间:2018-04-18 18:17:55

标签: android xamarin dotnet-httpclient

I have an out of the box (default template) xamarin forms application that I added a single http get to "google.com" on a button press. The CPU usage of the app is minimal until I make that web request. At that point it begins to use quite a bit of cpu - probably adding another .1s cpu usage every second or so (even while the app is backgrounded). I'm wondering why this is and if there are any solutions to it?

Here is an image showing the high CPU use: https://i.imgur.com/zKbx5FP.png

Here is the command for the button press:

public ICommand MakeRequestCommand
{
  get
  {
    return new Command(async () =>
    {
      HttpClient client = new HttpClient();
      await client.GetAsync("http://google.com");
    });
 }
}

0 个答案:

没有答案