C# ServicePointManager.DefaultConnectionLimit与HttpWebRequest的关系如何?

C# ServicePointManager.DefaultConnectionLimit与HttpWebRequest的关系如何?,c#,httpwebrequest,C#,Httpwebrequest,我想知道ServicePointManager.DefaultConnectionLimit与HttpWebRequest有什么关系 假设我设置了ServicePointManager.DefaultConnectionLimit=10,然后创建了20个线程,所有线程都需要向同一url发送请求。ServicePointManager.DefaultConnectionLimit是否仅限制10个线程发送请求,一旦完成,是否允许其他10个线程发送请求 比如说,代码看起来像这样: void send(

我想知道
ServicePointManager.DefaultConnectionLimit
与HttpWebRequest有什么关系

假设我设置了
ServicePointManager.DefaultConnectionLimit=10
,然后创建了20个线程,所有线程都需要向同一url发送请求。
ServicePointManager.DefaultConnectionLimit
是否仅限制10个线程发送请求,一旦完成,是否允许其他10个线程发送请求

比如说,代码看起来像这样:

void send() 
{
    ServicePointManager.DefaultConnectionLimit = 10;
    for (i < 20; i++) 
        {
            Task.Run( () => {
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(dmsUrl);
            ...
            Request.GetResponse();
        }
}
void send()
{
ServicePointManager.DefaultConnectionLimit=10;
对于(i<20;i++)
{
Task.Run(()=>{
HttpWebRequest请求=(HttpWebRequest)WebRequest.Create(dmsUrl);
...
Request.GetResponse();
}
}
了解一下这一点可能有助于您了解什么是ServicePoint,以及如何使用DefaultConnectionLimit和MaxServicePointIdle等混合设置来管理它。了解一下这一点可能有助于您了解什么是ServicePoint,以及如何使用DefaultConnectionLimit和MaxServicePointIdle等混合设置来管理它时间