HttpClient 是支持重入的

代码如下

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            var x = new HttpClient();
            var t1 = x.GetAsync("http://www.baidu.com");
            var t2 = x.GetAsync("http://www.zhihu.com");
            Task.WaitAll(t1, t2);
            Console.WriteLine(t1.Result.StatusCode);
            Console.WriteLine(t2.Result.StatusCode);
        }
    }
}

运行结果如下

OK
OK
请按任意键继续. . .

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注

ERROR: si-captcha.php plugin: GD image support not detected in PHP!

Contact your web host and ask them to enable GD image support for PHP.

ERROR: si-captcha.php plugin: imagepng function not detected in PHP!

Contact your web host and ask them to enable imagepng for PHP.

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据

Content is available under CC BY-SA 3.0 unless otherwise noted.