Limiting the number of Asynchronous WebClient requests

  • 13 years ago

    Hi everyone.

    I'm working on a roject which downloads a large number of files from the web using the WebClient class in VB.NET. I'm using its OpenReadAsync method to download the files on different threads for better performance. The problem is the performance is too good - the program is using all 25 threads in the threadpool to download the files at once which is too many simultaneous requests from one IP for some servers to tolerate.

    What I need to do is limit the number of simultaneous requests to 5 or 6. I have tried setting a counter for each active request and sleeping the main thread until the count comes back below the limit but have found that the main thread never awakens.

    Does anyone have any ideas?

    Cheers,

    Mike

  • 13 years ago
    You could use Application Start/End , Session Start / End to limit and monitor user connections and limit their user.  You can also limit connections via IIS.

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Nine people can't make a baby in a month.” - Fred Brooks