JC

A .NET Blog

<December 2008>
SuMoTuWeThFrSa
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910


Navigation

Subscriptions

Post Categories



ThreadPool

Do you know that the .NET ThreadPool class doesn't work well with HTTP connections ? 

http://www.dotnet247.com/247reference/msgs/15/76597.aspx :

It looks like when you hit around 22 threads in
the
ThreadPool class and the callback function is using HttpWebResponse
that you get the out of threads error. After doing some more digging it
looks like this is a bug with the HttpWebResponse and how it interacts with
the
ThreadPool class. They are looking at fixing this for the next release.

 I used it in Favalias to retrieve the favicons of the web sites that provide one. Since you can have many favorites, I executed asynchronous HTTP connections and used ThreadPool. But I had a lot of problems with HTTP connections that closed untimely (the error message is : "There were not enough free threads in the ThreadPool object to complete the operation.").
So, now, I always use the PriorityThreadPool class developed by Stephen Toub (The source code is in the Favalias source control or here). It is great because it is a managed class, you can change the threads' priority and the number of threads in the pool. And I haven't had any problems with it.

 

posted on Saturday, February 14, 2004 2:50 PM by jcmag





Powered by Dot Net Junkies, by Telligent Systems