I have written a utility which currently downloads xml data from a high
number (40+) of web based sources in a synchronous manner.
When attempting to spawn threads off to speed things up I run into
major problems due to blocking and number of threads available in the
thread pool.
Despite trying various methods (invoking delegates, counting threads in
order to try manage the threadpool, etc) none of these have worked as
hoped.
Basically all my code is doing is calling the following function:
internal myclass DeserializeMyClass(string url)
{
XmlSerializer serializer = new XmlSerializer(typeof(myclass));
myclass t = new myclass();
try
{
WebRequest wReq = WebRequest.Create(url);
WebResponse wRes = wReq.GetResponse(); // this is the culprit!!!
StreamReader strm = new StreamReader(wRes.GetResponseStream());
XmlTextReader xmlReader = new XmlTextReader(strm);
t = (myclass) serializer.Deserialize(xmlReader);
}
catch
{
// todo: log error
}
return t;
}
Can anyone point to how I could successfully do this in a
multi-threaded manner?