<分区>
从这里answer问题:Do HttpClient and HttpClientHandler have to be disposed? ,我发现最佳做法是不为每个 HTTP 请求处理 System.Net.Http.HttpClient
。特别声明:
standard usage of HttpClient is not to dispose of it after every request.
那很好。
我的问题是,这种“模式”是否也适用于 Windows.Web.Http.HttpClient
?还是应该根据 HTTP 请求处理它?我认为 documentation对此有点含糊。在其中一个示例中,它只是说明:
// Once your app is done using the HttpClient object call dispose to
// free up system resources (the underlying socket and memory used for the object)
httpclient.Dispose();
我相信这可以从两个方面来理解,因此欢迎任何关于此的具体输入。