How does ServicePointManager.DefaultConnectionLimit relate to HttpWebRequest?

856 Views Asked by At

I'm wondering how does ServicePointManager.DefaultConnectionLimit relate to the HttpWebRequest.

Let's say I set the ServicePointManager.DefaultConnectionLimit = 10 and then I create 20 threads that all need to send a request to the same url. Will the ServicePointManager.DefaultConnectionLimit limit only 10 threads to send their request, and once done allow the other 10?

Let's say the code looks something like that as an example:

void send() 
{
    ServicePointManager.DefaultConnectionLimit = 10;
    for (i < 20; i++) 
        {
            Task.Run( () => {
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(dmsUrl);
            ...
            Request.GetResponse();
        }
}
0

There are 0 best solutions below