UWP http客户端获得响应的延迟

时间:2017-06-24 21:42:45

标签: c# uwp httpclient delay sendasync

我发现了UWP HttpClient的这种特殊行为。

对于WCF服务的简单get调用,花费的时间几乎超过100秒(前几次调用会发生)。我发现iOS和休息客户端的相同服务速度太快了。

附上代码,如果我做错了,请告诉我。

            HttpClientHandler clientHandler = new HttpClientHandler();
            clientHandler.UseCookies = true;

            var client = new HttpClient(clientHandler);
            client.Timeout = TimeSpan.FromSeconds(100);

            client.DefaultRequestHeaders.Add("Accept", "application/json");

            var httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, 
            requestUri);
            var response = await client.SendAsync(httpRequestMessage);

            //Between these lines there is a delay, it doesnt fire time out 
            also. I tried with HttpCompletionOption. No luck

            if (response.IsSuccessStatusCode)
            {
                var content = await response.Content.ReadAsStringAsync(); 

            }

任何帮助都将非常感激。

谢谢和问候,

拉​​米

0 个答案:

没有答案