HttpClient在Xamarin Android上的响应时间非常长

时间:2018-07-10 10:33:57

标签: xamarin xamarin.android httpclient

我已关注文章https://docs.microsoft.com/en-gb/xamarin/android/app-fundamentals/http-stack?tabs=macos,以使Xamarin Android应用程序支持TLS 1.2

当我打电话给休息服务时,Xamarin Android需要10秒钟以上,而Xamarin IOS项目则需要2秒钟以上。

两个项目都使用相同的PLC HttpClient代码来调用相同的服务。

代码:

HttpClient client = new HttpClient();
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, restQuery);
response = await client.SendAsync(request);
string result = await response.Content.ReadAsStringAsync();

response = await client.SendAsync(request); 行需要花费大量时间来执行上述操作。

提出此问题是因为Xamarin中的IOS和Android环境之间存在很大差异。

0 个答案:

没有答案