Is there a known bug with the interaction between the HttpWebRequest and the
ThreadPool? I current spawn several HttpWebRequest's using
BeginGetResponse, and they work for a while, using worker threads from the
ThreadPool. However, eventually (relatively quickly) there become fewer and
fewer available worker threads in the pool, until there are 0 and a
System.InvalidOperationException occurs with the message: "There were not
enough free threads in the ThreadPool object to complete the operation."
It's as if the worker threads are never released by the HttpWebRequest,
which seems like a pretty serious bug.
Oh, and so far I only repro this on Win9x (ME to be precise, haven't tried
98 yet). The worker threads seem to be released fine by all of the NT
flavors.
Below I am including 2 things:
(a) The methods that work with the HttpWebRequest object
(b) The result of calling ThreadPool.GetAvailableThreads(out int
workerThreads, out int completionPortThreads) as I create each
HttpWebRequest (until the number of workers hits 0 at which point an
exception is thrown)
Thanks,
Dan
(a) basically I call these in a loop, such that no more than 8 are active
at any given time
public void BeginScrapeContent(ScraperConfig config) {
if (config == null) {
if (_config == null) {
throw new ArgumentNullException("config", "config or _config can not
be null.");
}
} else {
this._config = config;
}
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(this.Url);
request.BeginGetResponse(new AsyncCallback(EndRequestContent1), request);
}
private void EndRequestContent1(IAsyncResult ar) {
HttpWebRequest request = null;
try {
request = (HttpWebRequest)ar.AsyncState;
request.EndGetResponse(ar);
_content += new
StreamReader(request.GetResponse().GetResponseStre am()).ReadToEnd();
_contentRetrievalSuccess1 = true;
} catch (Exception ex) {
_contentRetrievalSuccess1 = false;
Debug.WriteLine(ex.Message);
_failReason = ex is WebException ? ContentRetrievalFailure.NoResponse :
ContentRetrievalFailure.BadResponse;
} finally {
try {
request.GetResponse().Close();
} catch {
Debug.WriteLine("Error calling close");
}
}
}
(b) Here's the result, of in that loop where I call the BeginScrapeContent
method), checking ThreadPool.GetAvailableThreads each time I perform a new
BeginScrapeContent call (again, there are ever only a max of 8 of these at
any time). As you can see the number of worker threads drops to 0 quite
quickly.
wrkThrds: 25 cpThrds: 25
wrkThrds: 25 cpThrds: 25
wrkThrds: 24 cpThrds: 25
wrkThrds: 24 cpThrds: 25
wrkThrds: 23 cpThrds: 25
wrkThrds: 21 cpThrds: 25
wrkThrds: 19 cpThrds: 25
wrkThrds: 19 cpThrds: 25
wrkThrds: 19 cpThrds: 25
wrkThrds: 17 cpThrds: 25
wrkThrds: 17 cpThrds: 25
wrkThrds: 19 cpThrds: 25
wrkThrds: 17 cpThrds: 25
wrkThrds: 17 cpThrds: 25
wrkThrds: 18 cpThrds: 25
wrkThrds: 17 cpThrds: 25
wrkThrds: 18 cpThrds: 25
wrkThrds: 18 cpThrds: 25
wrkThrds: 17 cpThrds: 25
wrkThrds: 17 cpThrds: 25
wrkThrds: 18 cpThrds: 25
wrkThrds: 17 cpThrds: 25
wrkThrds: 18 cpThrds: 25
wrkThrds: 17 cpThrds: 25
wrkThrds: 17 cpThrds: 25
wrkThrds: 18 cpThrds: 25
wrkThrds: 16 cpThrds: 25
wrkThrds: 17 cpThrds: 25
wrkThrds: 15 cpThrds: 25
wrkThrds: 16 cpThrds: 25
wrkThrds: 16 cpThrds: 25
wrkThrds: 13 cpThrds: 25
wrkThrds: 13 cpThrds: 25
wrkThrds: 12 cpThrds: 25
wrkThrds: 12 cpThrds: 25
wrkThrds: 12 cpThrds: 25
wrkThrds: 12 cpThrds: 25
wrkThrds: 11 cpThrds: 25
wrkThrds: 12 cpThrds: 25
wrkThrds: 12 cpThrds: 25
wrkThrds: 11 cpThrds: 25
wrkThrds: 10 cpThrds: 25
wrkThrds: 9 cpThrds: 25
wrkThrds: 8 cpThrds: 25
wrkThrds: 9 cpThrds: 25
wrkThrds: 9 cpThrds: 25
wrkThrds: 8 cpThrds: 25
wrkThrds: 8 cpThrds: 25
wrkThrds: 7 cpThrds: 25
wrkThrds: 12 cpThrds: 25
wrkThrds: 10 cpThrds: 25
wrkThrds: 10 cpThrds: 25
wrkThrds: 7 cpThrds: 25
wrkThrds: 9 cpThrds: 25
wrkThrds: 8 cpThrds: 25
wrkThrds: 11 cpThrds: 25
wrkThrds: 13 cpThrds: 25
wrkThrds: 13 cpThrds: 25
wrkThrds: 11 cpThrds: 25
wrkThrds: 10 cpThrds: 25
wrkThrds: 11 cpThrds: 25
wrkThrds: 9 cpThrds: 25
wrkThrds: 12 cpThrds: 25
wrkThrds: 11 cpThrds: 25
wrkThrds: 10 cpThrds: 25
wrkThrds: 8 cpThrds: 25
wrkThrds: 7 cpThrds: 25
wrkThrds: 7 cpThrds: 25
wrkThrds: 8 cpThrds: 25
wrkThrds: 8 cpThrds: 25
wrkThrds: 8 cpThrds: 25
wrkThrds: 10 cpThrds: 25
wrkThrds: 14 cpThrds: 25
wrkThrds: 18 cpThrds: 25
wrkThrds: 19 cpThrds: 25
wrkThrds: 17 cpThrds: 25
wrkThrds: 17 cpThrds: 25
wrkThrds: 17 cpThrds: 25
wrkThrds: 15 cpThrds: 25
wrkThrds: 15 cpThrds: 25
wrkThrds: 14 cpThrds: 25
wrkThrds: 14 cpThrds: 25
wrkThrds: 14 cpThrds: 25
wrkThrds: 14 cpThrds: 25
wrkThrds: 11 cpThrds: 25
wrkThrds: 10 cpThrds: 25
wrkThrds: 10 cpThrds: 25
wrkThrds: 10 cpThrds: 25
wrkThrds: 11 cpThrds: 25
wrkThrds: 11 cpThrds: 25
wrkThrds: 11 cpThrds: 25
wrkThrds: 10 cpThrds: 25
wrkThrds: 10 cpThrds: 25
wrkThrds: 8 cpThrds: 25
wrkThrds: 9 cpThrds: 25
wrkThrds: 10 cpThrds: 25
wrkThrds: 5 cpThrds: 25
wrkThrds: 5 cpThrds: 25
wrkThrds: 8 cpThrds: 25
wrkThrds: 7 cpThrds: 25
wrkThrds: 7 cpThrds: 25
wrkThrds: 5 cpThrds: 25
wrkThrds: 6 cpThrds: 25
wrkThrds: 5 cpThrds: 25
wrkThrds: 4 cpThrds: 25
wrkThrds: 3 cpThrds: 25
wrkThrds: 3 cpThrds: 25
wrkThrds: 1 cpThrds: 25
wrkThrds: 0 cpThrds: 25
Exception Type: System.InvalidOperationException
Message: There were not enough free threads in the ThreadPool object to
complete the operation.
Stack Trace:
at System.Net.HttpWebRequest.BeginGetResponse(AsyncCa llback callback,
Object state)
at TestApp.Retriever.BeginScrapeContent(ScraperConfig config)
at TestApp.Form1.RetrieveContentStart()
Source: System
Target Site: System.IAsyncResult BeginGetResponse(System.AsyncCallback,
System.Object) 5 12278
Your not the first to suffer from this bug.
You will need to manually count your invocations of threads and web
requests. Each web request will consume one thread from the pool, so each
method will use two pool calls. When the threaded method terminates deduct
two from your counter, one for the web request and one for the thread
method.
--
Regards
John Timney (Microsoft ASP.NET MVP)
----------------------------------------------
<shameless_author_plug>
Professional .NET for Java Developers with C#
ISBN:1-861007-91-4
Professional Windows Forms
ISBN: 1861005547
Professional JSP 2nd Edition
ISBN: 1861004958
Professional JSP
ISBN: 1861003625
Beginning JSP Web Development
ISBN: 1861002092
</shameless_author_plug>
----------------------------------------------
"Dan Battagin" <tu*******@certes.net> wrote in message
news:OM*******************@nwrddc01.gnilink.net... Is there a known bug with the interaction between the HttpWebRequest and
the ThreadPool? I current spawn several HttpWebRequest's using BeginGetResponse, and they work for a while, using worker threads from the ThreadPool. However, eventually (relatively quickly) there become fewer
and fewer available worker threads in the pool, until there are 0 and a System.InvalidOperationException occurs with the message: "There were not enough free threads in the ThreadPool object to complete the operation."
It's as if the worker threads are never released by the HttpWebRequest, which seems like a pretty serious bug.
Oh, and so far I only repro this on Win9x (ME to be precise, haven't tried 98 yet). The worker threads seem to be released fine by all of the NT flavors.
Below I am including 2 things: (a) The methods that work with the HttpWebRequest object (b) The result of calling ThreadPool.GetAvailableThreads(out int workerThreads, out int completionPortThreads) as I create each HttpWebRequest (until the number of workers hits 0 at which point an exception is thrown)
Thanks, Dan
(a) basically I call these in a loop, such that no more than 8 are active at any given time
public void BeginScrapeContent(ScraperConfig config) { if (config == null) { if (_config == null) { throw new ArgumentNullException("config", "config or _config can not be null."); } } else { this._config = config; } HttpWebRequest request = (HttpWebRequest)WebRequest.Create(this.Url); request.BeginGetResponse(new AsyncCallback(EndRequestContent1),
request); }
private void EndRequestContent1(IAsyncResult ar) { HttpWebRequest request = null; try { request = (HttpWebRequest)ar.AsyncState; request.EndGetResponse(ar); _content += new StreamReader(request.GetResponse().GetResponseStre am()).ReadToEnd(); _contentRetrievalSuccess1 = true; } catch (Exception ex) { _contentRetrievalSuccess1 = false; Debug.WriteLine(ex.Message); _failReason = ex is WebException ? ContentRetrievalFailure.NoResponse
: ContentRetrievalFailure.BadResponse; } finally { try { request.GetResponse().Close(); } catch { Debug.WriteLine("Error calling close"); } } }
(b) Here's the result, of in that loop where I call the
BeginScrapeContent method), checking ThreadPool.GetAvailableThreads each time I perform a new BeginScrapeContent call (again, there are ever only a max of 8 of these at any time). As you can see the number of worker threads drops to 0 quite quickly.
wrkThrds: 25 cpThrds: 25 wrkThrds: 25 cpThrds: 25 wrkThrds: 24 cpThrds: 25 wrkThrds: 24 cpThrds: 25 wrkThrds: 23 cpThrds: 25 wrkThrds: 21 cpThrds: 25 wrkThrds: 19 cpThrds: 25 wrkThrds: 19 cpThrds: 25 wrkThrds: 19 cpThrds: 25 wrkThrds: 17 cpThrds: 25 wrkThrds: 17 cpThrds: 25 wrkThrds: 19 cpThrds: 25 wrkThrds: 17 cpThrds: 25 wrkThrds: 17 cpThrds: 25 wrkThrds: 18 cpThrds: 25 wrkThrds: 17 cpThrds: 25 wrkThrds: 18 cpThrds: 25 wrkThrds: 18 cpThrds: 25 wrkThrds: 17 cpThrds: 25 wrkThrds: 17 cpThrds: 25 wrkThrds: 18 cpThrds: 25 wrkThrds: 17 cpThrds: 25 wrkThrds: 18 cpThrds: 25 wrkThrds: 17 cpThrds: 25 wrkThrds: 17 cpThrds: 25 wrkThrds: 18 cpThrds: 25 wrkThrds: 16 cpThrds: 25 wrkThrds: 17 cpThrds: 25 wrkThrds: 15 cpThrds: 25 wrkThrds: 16 cpThrds: 25 wrkThrds: 16 cpThrds: 25 wrkThrds: 13 cpThrds: 25 wrkThrds: 13 cpThrds: 25 wrkThrds: 12 cpThrds: 25 wrkThrds: 12 cpThrds: 25 wrkThrds: 12 cpThrds: 25 wrkThrds: 12 cpThrds: 25 wrkThrds: 11 cpThrds: 25 wrkThrds: 12 cpThrds: 25 wrkThrds: 12 cpThrds: 25 wrkThrds: 11 cpThrds: 25 wrkThrds: 10 cpThrds: 25 wrkThrds: 9 cpThrds: 25 wrkThrds: 8 cpThrds: 25 wrkThrds: 9 cpThrds: 25 wrkThrds: 9 cpThrds: 25 wrkThrds: 8 cpThrds: 25 wrkThrds: 8 cpThrds: 25 wrkThrds: 7 cpThrds: 25 wrkThrds: 12 cpThrds: 25 wrkThrds: 10 cpThrds: 25 wrkThrds: 10 cpThrds: 25 wrkThrds: 7 cpThrds: 25 wrkThrds: 9 cpThrds: 25 wrkThrds: 8 cpThrds: 25 wrkThrds: 11 cpThrds: 25 wrkThrds: 13 cpThrds: 25 wrkThrds: 13 cpThrds: 25 wrkThrds: 11 cpThrds: 25 wrkThrds: 10 cpThrds: 25 wrkThrds: 11 cpThrds: 25 wrkThrds: 9 cpThrds: 25 wrkThrds: 12 cpThrds: 25 wrkThrds: 11 cpThrds: 25 wrkThrds: 10 cpThrds: 25 wrkThrds: 8 cpThrds: 25 wrkThrds: 7 cpThrds: 25 wrkThrds: 7 cpThrds: 25 wrkThrds: 8 cpThrds: 25 wrkThrds: 8 cpThrds: 25 wrkThrds: 8 cpThrds: 25 wrkThrds: 10 cpThrds: 25 wrkThrds: 14 cpThrds: 25 wrkThrds: 18 cpThrds: 25 wrkThrds: 19 cpThrds: 25 wrkThrds: 17 cpThrds: 25 wrkThrds: 17 cpThrds: 25 wrkThrds: 17 cpThrds: 25 wrkThrds: 15 cpThrds: 25 wrkThrds: 15 cpThrds: 25 wrkThrds: 14 cpThrds: 25 wrkThrds: 14 cpThrds: 25 wrkThrds: 14 cpThrds: 25 wrkThrds: 14 cpThrds: 25 wrkThrds: 11 cpThrds: 25 wrkThrds: 10 cpThrds: 25 wrkThrds: 10 cpThrds: 25 wrkThrds: 10 cpThrds: 25 wrkThrds: 11 cpThrds: 25 wrkThrds: 11 cpThrds: 25 wrkThrds: 11 cpThrds: 25 wrkThrds: 10 cpThrds: 25 wrkThrds: 10 cpThrds: 25 wrkThrds: 8 cpThrds: 25 wrkThrds: 9 cpThrds: 25 wrkThrds: 10 cpThrds: 25 wrkThrds: 5 cpThrds: 25 wrkThrds: 5 cpThrds: 25 wrkThrds: 8 cpThrds: 25 wrkThrds: 7 cpThrds: 25 wrkThrds: 7 cpThrds: 25 wrkThrds: 5 cpThrds: 25 wrkThrds: 6 cpThrds: 25 wrkThrds: 5 cpThrds: 25 wrkThrds: 4 cpThrds: 25 wrkThrds: 3 cpThrds: 25 wrkThrds: 3 cpThrds: 25 wrkThrds: 1 cpThrds: 25 wrkThrds: 0 cpThrds: 25
Exception Type: System.InvalidOperationException Message: There were not enough free threads in the ThreadPool object to complete the operation. Stack Trace: at System.Net.HttpWebRequest.BeginGetResponse(AsyncCa llback callback, Object state) at TestApp.Retriever.BeginScrapeContent(ScraperConfig config) at TestApp.Form1.RetrieveContentStart() Source: System Target Site: System.IAsyncResult BeginGetResponse(System.AsyncCallback, System.Object)
This is by design, you should handle the exception See Q815637.
Willy.
Dan Battagin wrote:
|| Is there a known bug with the interaction between the HttpWebRequest
|| and the ThreadPool? I current spawn several HttpWebRequest's using
|| BeginGetResponse, and they work for a while, using worker threads
|| from the ThreadPool. However, eventually (relatively quickly) there
|| become fewer and fewer available worker threads in the pool, until
|| there are 0 and a System.InvalidOperationException occurs with the
|| message: "There were not enough free threads in the ThreadPool
|| object to complete the operation."
||
|| It's as if the worker threads are never released by the
|| HttpWebRequest, which seems like a pretty serious bug.
||
|| Oh, and so far I only repro this on Win9x (ME to be precise, haven't
|| tried 98 yet). The worker threads seem to be released fine by all
|| of the NT flavors.
||
|| Below I am including 2 things:
|| (a) The methods that work with the HttpWebRequest object
|| (b) The result of calling ThreadPool.GetAvailableThreads(out int
|| workerThreads, out int completionPortThreads) as I create each
|| HttpWebRequest (until the number of workers hits 0 at which point an
|| exception is thrown)
||
|| Thanks,
|| Dan
||
|| (a) basically I call these in a loop, such that no more than 8 are
|| active at any given time
||
|| public void BeginScrapeContent(ScraperConfig config) {
|| if (config == null) {
|| if (_config == null) {
|| throw new ArgumentNullException("config", "config or _config
|| can not be null.");
|| }
|| } else {
|| this._config = config;
|| }
|| HttpWebRequest request =
|| (HttpWebRequest)WebRequest.Create(this.Url);
|| request.BeginGetResponse(new AsyncCallback(EndRequestContent1),
|| request); }
||
|| private void EndRequestContent1(IAsyncResult ar) {
|| HttpWebRequest request = null;
|| try {
|| request = (HttpWebRequest)ar.AsyncState;
|| request.EndGetResponse(ar);
|| _content += new
|| StreamReader(request.GetResponse().GetResponseStre am()).ReadToEnd();
|| _contentRetrievalSuccess1 = true;
|| } catch (Exception ex) {
|| _contentRetrievalSuccess1 = false;
|| Debug.WriteLine(ex.Message);
|| _failReason = ex is WebException ?
|| ContentRetrievalFailure.NoResponse :
|| ContentRetrievalFailure.BadResponse; } finally {
|| try {
|| request.GetResponse().Close();
|| } catch {
|| Debug.WriteLine("Error calling close");
|| }
|| }
|| }
||
|| (b) Here's the result, of in that loop where I call the
|| BeginScrapeContent method), checking ThreadPool.GetAvailableThreads
|| each time I perform a new BeginScrapeContent call (again, there are
|| ever only a max of 8 of these at any time). As you can see the
|| number of worker threads drops to 0 quite quickly.
||
|| wrkThrds: 25 cpThrds: 25
|| wrkThrds: 25 cpThrds: 25
|| wrkThrds: 24 cpThrds: 25
|| wrkThrds: 24 cpThrds: 25
|| wrkThrds: 23 cpThrds: 25
|| wrkThrds: 21 cpThrds: 25
|| wrkThrds: 19 cpThrds: 25
|| wrkThrds: 19 cpThrds: 25
|| wrkThrds: 19 cpThrds: 25
|| wrkThrds: 17 cpThrds: 25
|| wrkThrds: 17 cpThrds: 25
|| wrkThrds: 19 cpThrds: 25
|| wrkThrds: 17 cpThrds: 25
|| wrkThrds: 17 cpThrds: 25
|| wrkThrds: 18 cpThrds: 25
|| wrkThrds: 17 cpThrds: 25
|| wrkThrds: 18 cpThrds: 25
|| wrkThrds: 18 cpThrds: 25
|| wrkThrds: 17 cpThrds: 25
|| wrkThrds: 17 cpThrds: 25
|| wrkThrds: 18 cpThrds: 25
|| wrkThrds: 17 cpThrds: 25
|| wrkThrds: 18 cpThrds: 25
|| wrkThrds: 17 cpThrds: 25
|| wrkThrds: 17 cpThrds: 25
|| wrkThrds: 18 cpThrds: 25
|| wrkThrds: 16 cpThrds: 25
|| wrkThrds: 17 cpThrds: 25
|| wrkThrds: 15 cpThrds: 25
|| wrkThrds: 16 cpThrds: 25
|| wrkThrds: 16 cpThrds: 25
|| wrkThrds: 13 cpThrds: 25
|| wrkThrds: 13 cpThrds: 25
|| wrkThrds: 12 cpThrds: 25
|| wrkThrds: 12 cpThrds: 25
|| wrkThrds: 12 cpThrds: 25
|| wrkThrds: 12 cpThrds: 25
|| wrkThrds: 11 cpThrds: 25
|| wrkThrds: 12 cpThrds: 25
|| wrkThrds: 12 cpThrds: 25
|| wrkThrds: 11 cpThrds: 25
|| wrkThrds: 10 cpThrds: 25
|| wrkThrds: 9 cpThrds: 25
|| wrkThrds: 8 cpThrds: 25
|| wrkThrds: 9 cpThrds: 25
|| wrkThrds: 9 cpThrds: 25
|| wrkThrds: 8 cpThrds: 25
|| wrkThrds: 8 cpThrds: 25
|| wrkThrds: 7 cpThrds: 25
|| wrkThrds: 12 cpThrds: 25
|| wrkThrds: 10 cpThrds: 25
|| wrkThrds: 10 cpThrds: 25
|| wrkThrds: 7 cpThrds: 25
|| wrkThrds: 9 cpThrds: 25
|| wrkThrds: 8 cpThrds: 25
|| wrkThrds: 11 cpThrds: 25
|| wrkThrds: 13 cpThrds: 25
|| wrkThrds: 13 cpThrds: 25
|| wrkThrds: 11 cpThrds: 25
|| wrkThrds: 10 cpThrds: 25
|| wrkThrds: 11 cpThrds: 25
|| wrkThrds: 9 cpThrds: 25
|| wrkThrds: 12 cpThrds: 25
|| wrkThrds: 11 cpThrds: 25
|| wrkThrds: 10 cpThrds: 25
|| wrkThrds: 8 cpThrds: 25
|| wrkThrds: 7 cpThrds: 25
|| wrkThrds: 7 cpThrds: 25
|| wrkThrds: 8 cpThrds: 25
|| wrkThrds: 8 cpThrds: 25
|| wrkThrds: 8 cpThrds: 25
|| wrkThrds: 10 cpThrds: 25
|| wrkThrds: 14 cpThrds: 25
|| wrkThrds: 18 cpThrds: 25
|| wrkThrds: 19 cpThrds: 25
|| wrkThrds: 17 cpThrds: 25
|| wrkThrds: 17 cpThrds: 25
|| wrkThrds: 17 cpThrds: 25
|| wrkThrds: 15 cpThrds: 25
|| wrkThrds: 15 cpThrds: 25
|| wrkThrds: 14 cpThrds: 25
|| wrkThrds: 14 cpThrds: 25
|| wrkThrds: 14 cpThrds: 25
|| wrkThrds: 14 cpThrds: 25
|| wrkThrds: 11 cpThrds: 25
|| wrkThrds: 10 cpThrds: 25
|| wrkThrds: 10 cpThrds: 25
|| wrkThrds: 10 cpThrds: 25
|| wrkThrds: 11 cpThrds: 25
|| wrkThrds: 11 cpThrds: 25
|| wrkThrds: 11 cpThrds: 25
|| wrkThrds: 10 cpThrds: 25
|| wrkThrds: 10 cpThrds: 25
|| wrkThrds: 8 cpThrds: 25
|| wrkThrds: 9 cpThrds: 25
|| wrkThrds: 10 cpThrds: 25
|| wrkThrds: 5 cpThrds: 25
|| wrkThrds: 5 cpThrds: 25
|| wrkThrds: 8 cpThrds: 25
|| wrkThrds: 7 cpThrds: 25
|| wrkThrds: 7 cpThrds: 25
|| wrkThrds: 5 cpThrds: 25
|| wrkThrds: 6 cpThrds: 25
|| wrkThrds: 5 cpThrds: 25
|| wrkThrds: 4 cpThrds: 25
|| wrkThrds: 3 cpThrds: 25
|| wrkThrds: 3 cpThrds: 25
|| wrkThrds: 1 cpThrds: 25
|| wrkThrds: 0 cpThrds: 25
||
|| Exception Type: System.InvalidOperationException
|| Message: There were not enough free threads in the ThreadPool
|| object to complete the operation.
|| Stack Trace:
|| at System.Net.HttpWebRequest.BeginGetResponse(AsyncCa llback
|| callback, Object state)
|| at TestApp.Retriever.BeginScrapeContent(ScraperConfig config)
|| at TestApp.Form1.RetrieveContentStart()
|| Source: System
|| Target Site: System.IAsyncResult
|| BeginGetResponse(System.AsyncCallback, System.Object)
John,
Thanks for the reply. My question though: I think I am already doing this.
I've included a bit more of the code that I am using. This is the code that
calls the BeginScrapeContent below. Note how I only call that method if
there are 8 or fewer active requests.
It's as though, even though I am doing that, the worker threads are never
being released...I've also tried checking in the while loop for the number
of available worker threads and sleeping if there are less than 5, but that
doesn't work either (app just hangs)
Thoughts?
Thanks,
Dan
for (int i=0; i<items.Count; i++) {
if (_stop == false) {
Interlocked.Increment(ref _activeRequests);
while (_activeRequests > 8) {
Thread.Sleep(100);
}
s = new Scraper(items[i].ToString());
s.ContentRetrievalComplete += new
ContentRetrievalCompleteEventHandler(this.Retrieve ScraperComplete);
s.BeginScrapeContent(config);
}
....
(and then in RetrieveScraperComplete)
....
Interlocked.Decrement(_activeRequests);
"John Timney (Microsoft MVP)" <xy********@btinternet.com> wrote in message
news:OT****************@TK2MSFTNGP10.phx.gbl... Your not the first to suffer from this bug.
You will need to manually count your invocations of threads and web requests. Each web request will consume one thread from the pool, so each method will use two pool calls. When the threaded method terminates
deduct two from your counter, one for the web request and one for the thread method.
-- Regards
John Timney (Microsoft ASP.NET MVP) ---------------------------------------------- <shameless_author_plug> Professional .NET for Java Developers with C# ISBN:1-861007-91-4 Professional Windows Forms ISBN: 1861005547 Professional JSP 2nd Edition ISBN: 1861004958 Professional JSP ISBN: 1861003625 Beginning JSP Web Development ISBN: 1861002092 </shameless_author_plug> ----------------------------------------------
"Dan Battagin" <tu*******@certes.net> wrote in message news:OM*******************@nwrddc01.gnilink.net... Is there a known bug with the interaction between the HttpWebRequest and the ThreadPool? I current spawn several HttpWebRequest's using BeginGetResponse, and they work for a while, using worker threads from
the ThreadPool. However, eventually (relatively quickly) there become fewer and fewer available worker threads in the pool, until there are 0 and a System.InvalidOperationException occurs with the message: "There were
not enough free threads in the ThreadPool object to complete the operation."
It's as if the worker threads are never released by the HttpWebRequest, which seems like a pretty serious bug.
Oh, and so far I only repro this on Win9x (ME to be precise, haven't
tried 98 yet). The worker threads seem to be released fine by all of the NT flavors.
Below I am including 2 things: (a) The methods that work with the HttpWebRequest object (b) The result of calling ThreadPool.GetAvailableThreads(out int workerThreads, out int completionPortThreads) as I create each HttpWebRequest (until the number of workers hits 0 at which point an exception is thrown)
Thanks, Dan
(a) basically I call these in a loop, such that no more than 8 are
active at any given time
public void BeginScrapeContent(ScraperConfig config) { if (config == null) { if (_config == null) { throw new ArgumentNullException("config", "config or _config can
not be null."); } } else { this._config = config; } HttpWebRequest request = (HttpWebRequest)WebRequest.Create(this.Url); request.BeginGetResponse(new AsyncCallback(EndRequestContent1), request); }
private void EndRequestContent1(IAsyncResult ar) { HttpWebRequest request = null; try { request = (HttpWebRequest)ar.AsyncState; request.EndGetResponse(ar); _content += new StreamReader(request.GetResponse().GetResponseStre am()).ReadToEnd(); _contentRetrievalSuccess1 = true; } catch (Exception ex) { _contentRetrievalSuccess1 = false; Debug.WriteLine(ex.Message); _failReason = ex is WebException ?
ContentRetrievalFailure.NoResponse : ContentRetrievalFailure.BadResponse; } finally { try { request.GetResponse().Close(); } catch { Debug.WriteLine("Error calling close"); } } }
(b) Here's the result, of in that loop where I call the BeginScrapeContent method), checking ThreadPool.GetAvailableThreads each time I perform a
new BeginScrapeContent call (again, there are ever only a max of 8 of these
at any time). As you can see the number of worker threads drops to 0 quite quickly.
wrkThrds: 25 cpThrds: 25 wrkThrds: 25 cpThrds: 25 wrkThrds: 24 cpThrds: 25 wrkThrds: 24 cpThrds: 25 wrkThrds: 23 cpThrds: 25 wrkThrds: 21 cpThrds: 25 wrkThrds: 19 cpThrds: 25 wrkThrds: 19 cpThrds: 25 wrkThrds: 19 cpThrds: 25 wrkThrds: 17 cpThrds: 25 wrkThrds: 17 cpThrds: 25 wrkThrds: 19 cpThrds: 25 wrkThrds: 17 cpThrds: 25 wrkThrds: 17 cpThrds: 25 wrkThrds: 18 cpThrds: 25 wrkThrds: 17 cpThrds: 25 wrkThrds: 18 cpThrds: 25 wrkThrds: 18 cpThrds: 25 wrkThrds: 17 cpThrds: 25 wrkThrds: 17 cpThrds: 25 wrkThrds: 18 cpThrds: 25 wrkThrds: 17 cpThrds: 25 wrkThrds: 18 cpThrds: 25 wrkThrds: 17 cpThrds: 25 wrkThrds: 17 cpThrds: 25 wrkThrds: 18 cpThrds: 25 wrkThrds: 16 cpThrds: 25 wrkThrds: 17 cpThrds: 25 wrkThrds: 15 cpThrds: 25 wrkThrds: 16 cpThrds: 25 wrkThrds: 16 cpThrds: 25 wrkThrds: 13 cpThrds: 25 wrkThrds: 13 cpThrds: 25 wrkThrds: 12 cpThrds: 25 wrkThrds: 12 cpThrds: 25 wrkThrds: 12 cpThrds: 25 wrkThrds: 12 cpThrds: 25 wrkThrds: 11 cpThrds: 25 wrkThrds: 12 cpThrds: 25 wrkThrds: 12 cpThrds: 25 wrkThrds: 11 cpThrds: 25 wrkThrds: 10 cpThrds: 25 wrkThrds: 9 cpThrds: 25 wrkThrds: 8 cpThrds: 25 wrkThrds: 9 cpThrds: 25 wrkThrds: 9 cpThrds: 25 wrkThrds: 8 cpThrds: 25 wrkThrds: 8 cpThrds: 25 wrkThrds: 7 cpThrds: 25 wrkThrds: 12 cpThrds: 25 wrkThrds: 10 cpThrds: 25 wrkThrds: 10 cpThrds: 25 wrkThrds: 7 cpThrds: 25 wrkThrds: 9 cpThrds: 25 wrkThrds: 8 cpThrds: 25 wrkThrds: 11 cpThrds: 25 wrkThrds: 13 cpThrds: 25 wrkThrds: 13 cpThrds: 25 wrkThrds: 11 cpThrds: 25 wrkThrds: 10 cpThrds: 25 wrkThrds: 11 cpThrds: 25 wrkThrds: 9 cpThrds: 25 wrkThrds: 12 cpThrds: 25 wrkThrds: 11 cpThrds: 25 wrkThrds: 10 cpThrds: 25 wrkThrds: 8 cpThrds: 25 wrkThrds: 7 cpThrds: 25 wrkThrds: 7 cpThrds: 25 wrkThrds: 8 cpThrds: 25 wrkThrds: 8 cpThrds: 25 wrkThrds: 8 cpThrds: 25 wrkThrds: 10 cpThrds: 25 wrkThrds: 14 cpThrds: 25 wrkThrds: 18 cpThrds: 25 wrkThrds: 19 cpThrds: 25 wrkThrds: 17 cpThrds: 25 wrkThrds: 17 cpThrds: 25 wrkThrds: 17 cpThrds: 25 wrkThrds: 15 cpThrds: 25 wrkThrds: 15 cpThrds: 25 wrkThrds: 14 cpThrds: 25 wrkThrds: 14 cpThrds: 25 wrkThrds: 14 cpThrds: 25 wrkThrds: 14 cpThrds: 25 wrkThrds: 11 cpThrds: 25 wrkThrds: 10 cpThrds: 25 wrkThrds: 10 cpThrds: 25 wrkThrds: 10 cpThrds: 25 wrkThrds: 11 cpThrds: 25 wrkThrds: 11 cpThrds: 25 wrkThrds: 11 cpThrds: 25 wrkThrds: 10 cpThrds: 25 wrkThrds: 10 cpThrds: 25 wrkThrds: 8 cpThrds: 25 wrkThrds: 9 cpThrds: 25 wrkThrds: 10 cpThrds: 25 wrkThrds: 5 cpThrds: 25 wrkThrds: 5 cpThrds: 25 wrkThrds: 8 cpThrds: 25 wrkThrds: 7 cpThrds: 25 wrkThrds: 7 cpThrds: 25 wrkThrds: 5 cpThrds: 25 wrkThrds: 6 cpThrds: 25 wrkThrds: 5 cpThrds: 25 wrkThrds: 4 cpThrds: 25 wrkThrds: 3 cpThrds: 25 wrkThrds: 3 cpThrds: 25 wrkThrds: 1 cpThrds: 25 wrkThrds: 0 cpThrds: 25
Exception Type: System.InvalidOperationException Message: There were not enough free threads in the ThreadPool object to complete the operation. Stack Trace: at System.Net.HttpWebRequest.BeginGetResponse(AsyncCa llback callback, Object state) at TestApp.Retriever.BeginScrapeContent(ScraperConfig config) at TestApp.Form1.RetrieveContentStart() Source: System Target Site: System.IAsyncResult BeginGetResponse(System.AsyncCallback, System.Object)
Willy, I could go for that, but I dont think it will work - the worker
threads never seem to free up, and once they get to 0 I'm hosed...
Do you have an example of what I should do? (Also, I replied to John's
response as well, you might want to check that out)
Thanks much for your time,
Dan
"Willy Denoyette [MVP]" <wi*************@skynet.be> wrote in message
news:OC**************@tk2msftngp13.phx.gbl... This is by design, you should handle the exception See Q815637.
Willy.
Dan Battagin wrote: || Is there a known bug with the interaction between the HttpWebRequest || and the ThreadPool? I current spawn several HttpWebRequest's using || BeginGetResponse, and they work for a while, using worker threads || from the ThreadPool. However, eventually (relatively quickly) there || become fewer and fewer available worker threads in the pool, until || there are 0 and a System.InvalidOperationException occurs with the || message: "There were not enough free threads in the ThreadPool || object to complete the operation." || || It's as if the worker threads are never released by the || HttpWebRequest, which seems like a pretty serious bug. || || Oh, and so far I only repro this on Win9x (ME to be precise, haven't || tried 98 yet). The worker threads seem to be released fine by all || of the NT flavors. || || Below I am including 2 things: || (a) The methods that work with the HttpWebRequest object || (b) The result of calling ThreadPool.GetAvailableThreads(out int || workerThreads, out int completionPortThreads) as I create each || HttpWebRequest (until the number of workers hits 0 at which point an || exception is thrown) || || Thanks, || Dan || || (a) basically I call these in a loop, such that no more than 8 are || active at any given time || || public void BeginScrapeContent(ScraperConfig config) { || if (config == null) { || if (_config == null) { || throw new ArgumentNullException("config", "config or _config || can not be null."); || } || } else { || this._config = config; || } || HttpWebRequest request = || (HttpWebRequest)WebRequest.Create(this.Url); || request.BeginGetResponse(new AsyncCallback(EndRequestContent1), || request); } || || private void EndRequestContent1(IAsyncResult ar) { || HttpWebRequest request = null; || try { || request = (HttpWebRequest)ar.AsyncState; || request.EndGetResponse(ar); || _content += new || StreamReader(request.GetResponse().GetResponseStre am()).ReadToEnd(); || _contentRetrievalSuccess1 = true; || } catch (Exception ex) { || _contentRetrievalSuccess1 = false; || Debug.WriteLine(ex.Message); || _failReason = ex is WebException ? || ContentRetrievalFailure.NoResponse : || ContentRetrievalFailure.BadResponse; } finally { || try { || request.GetResponse().Close(); || } catch { || Debug.WriteLine("Error calling close"); || } || } || } || || (b) Here's the result, of in that loop where I call the || BeginScrapeContent method), checking ThreadPool.GetAvailableThreads || each time I perform a new BeginScrapeContent call (again, there are || ever only a max of 8 of these at any time). As you can see the || number of worker threads drops to 0 quite quickly. || || wrkThrds: 25 cpThrds: 25 || wrkThrds: 25 cpThrds: 25 || wrkThrds: 24 cpThrds: 25 || wrkThrds: 24 cpThrds: 25 || wrkThrds: 23 cpThrds: 25 || wrkThrds: 21 cpThrds: 25 || wrkThrds: 19 cpThrds: 25 || wrkThrds: 19 cpThrds: 25 || wrkThrds: 19 cpThrds: 25 || wrkThrds: 17 cpThrds: 25 || wrkThrds: 17 cpThrds: 25 || wrkThrds: 19 cpThrds: 25 || wrkThrds: 17 cpThrds: 25 || wrkThrds: 17 cpThrds: 25 || wrkThrds: 18 cpThrds: 25 || wrkThrds: 17 cpThrds: 25 || wrkThrds: 18 cpThrds: 25 || wrkThrds: 18 cpThrds: 25 || wrkThrds: 17 cpThrds: 25 || wrkThrds: 17 cpThrds: 25 || wrkThrds: 18 cpThrds: 25 || wrkThrds: 17 cpThrds: 25 || wrkThrds: 18 cpThrds: 25 || wrkThrds: 17 cpThrds: 25 || wrkThrds: 17 cpThrds: 25 || wrkThrds: 18 cpThrds: 25 || wrkThrds: 16 cpThrds: 25 || wrkThrds: 17 cpThrds: 25 || wrkThrds: 15 cpThrds: 25 || wrkThrds: 16 cpThrds: 25 || wrkThrds: 16 cpThrds: 25 || wrkThrds: 13 cpThrds: 25 || wrkThrds: 13 cpThrds: 25 || wrkThrds: 12 cpThrds: 25 || wrkThrds: 12 cpThrds: 25 || wrkThrds: 12 cpThrds: 25 || wrkThrds: 12 cpThrds: 25 || wrkThrds: 11 cpThrds: 25 || wrkThrds: 12 cpThrds: 25 || wrkThrds: 12 cpThrds: 25 || wrkThrds: 11 cpThrds: 25 || wrkThrds: 10 cpThrds: 25 || wrkThrds: 9 cpThrds: 25 || wrkThrds: 8 cpThrds: 25 || wrkThrds: 9 cpThrds: 25 || wrkThrds: 9 cpThrds: 25 || wrkThrds: 8 cpThrds: 25 || wrkThrds: 8 cpThrds: 25 || wrkThrds: 7 cpThrds: 25 || wrkThrds: 12 cpThrds: 25 || wrkThrds: 10 cpThrds: 25 || wrkThrds: 10 cpThrds: 25 || wrkThrds: 7 cpThrds: 25 || wrkThrds: 9 cpThrds: 25 || wrkThrds: 8 cpThrds: 25 || wrkThrds: 11 cpThrds: 25 || wrkThrds: 13 cpThrds: 25 || wrkThrds: 13 cpThrds: 25 || wrkThrds: 11 cpThrds: 25 || wrkThrds: 10 cpThrds: 25 || wrkThrds: 11 cpThrds: 25 || wrkThrds: 9 cpThrds: 25 || wrkThrds: 12 cpThrds: 25 || wrkThrds: 11 cpThrds: 25 || wrkThrds: 10 cpThrds: 25 || wrkThrds: 8 cpThrds: 25 || wrkThrds: 7 cpThrds: 25 || wrkThrds: 7 cpThrds: 25 || wrkThrds: 8 cpThrds: 25 || wrkThrds: 8 cpThrds: 25 || wrkThrds: 8 cpThrds: 25 || wrkThrds: 10 cpThrds: 25 || wrkThrds: 14 cpThrds: 25 || wrkThrds: 18 cpThrds: 25 || wrkThrds: 19 cpThrds: 25 || wrkThrds: 17 cpThrds: 25 || wrkThrds: 17 cpThrds: 25 || wrkThrds: 17 cpThrds: 25 || wrkThrds: 15 cpThrds: 25 || wrkThrds: 15 cpThrds: 25 || wrkThrds: 14 cpThrds: 25 || wrkThrds: 14 cpThrds: 25 || wrkThrds: 14 cpThrds: 25 || wrkThrds: 14 cpThrds: 25 || wrkThrds: 11 cpThrds: 25 || wrkThrds: 10 cpThrds: 25 || wrkThrds: 10 cpThrds: 25 || wrkThrds: 10 cpThrds: 25 || wrkThrds: 11 cpThrds: 25 || wrkThrds: 11 cpThrds: 25 || wrkThrds: 11 cpThrds: 25 || wrkThrds: 10 cpThrds: 25 || wrkThrds: 10 cpThrds: 25 || wrkThrds: 8 cpThrds: 25 || wrkThrds: 9 cpThrds: 25 || wrkThrds: 10 cpThrds: 25 || wrkThrds: 5 cpThrds: 25 || wrkThrds: 5 cpThrds: 25 || wrkThrds: 8 cpThrds: 25 || wrkThrds: 7 cpThrds: 25 || wrkThrds: 7 cpThrds: 25 || wrkThrds: 5 cpThrds: 25 || wrkThrds: 6 cpThrds: 25 || wrkThrds: 5 cpThrds: 25 || wrkThrds: 4 cpThrds: 25 || wrkThrds: 3 cpThrds: 25 || wrkThrds: 3 cpThrds: 25 || wrkThrds: 1 cpThrds: 25 || wrkThrds: 0 cpThrds: 25 || || Exception Type: System.InvalidOperationException || Message: There were not enough free threads in the ThreadPool || object to complete the operation. || Stack Trace: || at System.Net.HttpWebRequest.BeginGetResponse(AsyncCa llback || callback, Object state) || at TestApp.Retriever.BeginScrapeContent(ScraperConfig config) || at TestApp.Form1.RetrieveContentStart() || Source: System || Target Site: System.IAsyncResult || BeginGetResponse(System.AsyncCallback, System.Object)
You could use your own threadpool class - then you could set the threadpool
limit as high as you want, and you would get a lot more control over
when/how the threads were terminating. If nothing else it might shed some
light on why the threadpool threads are not terminating. There are several
implementations of a threadpool object around - you should be able to google
one up, or search the MSFT .NET newsgroups for an earlier posting of same.
BTW: we use WebRequests and don't have this problem, so something else is
undoubtedly going on in your app.
"Dan Battagin" <tu*******@certes.net> wrote in message
news:X8******************@nwrddc02.gnilink.net... Willy, I could go for that, but I dont think it will work - the worker threads never seem to free up, and once they get to 0 I'm hosed...
Do you have an example of what I should do? (Also, I replied to John's response as well, you might want to check that out)
Thanks much for your time, Dan
"Willy Denoyette [MVP]" <wi*************@skynet.be> wrote in message news:OC**************@tk2msftngp13.phx.gbl... This is by design, you should handle the exception See Q815637.
Willy.
Dan Battagin wrote: || Is there a known bug with the interaction between the HttpWebRequest || and the ThreadPool? I current spawn several HttpWebRequest's using || BeginGetResponse, and they work for a while, using worker threads || from the ThreadPool. However, eventually (relatively quickly) there || become fewer and fewer available worker threads in the pool, until || there are 0 and a System.InvalidOperationException occurs with the || message: "There were not enough free threads in the ThreadPool || object to complete the operation." || || It's as if the worker threads are never released by the || HttpWebRequest, which seems like a pretty serious bug. || || Oh, and so far I only repro this on Win9x (ME to be precise, haven't || tried 98 yet). The worker threads seem to be released fine by all || of the NT flavors. || || Below I am including 2 things: || (a) The methods that work with the HttpWebRequest object || (b) The result of calling ThreadPool.GetAvailableThreads(out int || workerThreads, out int completionPortThreads) as I create each || HttpWebRequest (until the number of workers hits 0 at which point an || exception is thrown) || || Thanks, || Dan || || (a) basically I call these in a loop, such that no more than 8 are || active at any given time || || public void BeginScrapeContent(ScraperConfig config) { || if (config == null) { || if (_config == null) { || throw new ArgumentNullException("config", "config or _config || can not be null."); || } || } else { || this._config = config; || } || HttpWebRequest request = || (HttpWebRequest)WebRequest.Create(this.Url); || request.BeginGetResponse(new AsyncCallback(EndRequestContent1), || request); } || || private void EndRequestContent1(IAsyncResult ar) { || HttpWebRequest request = null; || try { || request = (HttpWebRequest)ar.AsyncState; || request.EndGetResponse(ar); || _content += new || StreamReader(request.GetResponse().GetResponseStre am()).ReadToEnd(); || _contentRetrievalSuccess1 = true; || } catch (Exception ex) { || _contentRetrievalSuccess1 = false; || Debug.WriteLine(ex.Message); || _failReason = ex is WebException ? || ContentRetrievalFailure.NoResponse : || ContentRetrievalFailure.BadResponse; } finally { || try { || request.GetResponse().Close(); || } catch { || Debug.WriteLine("Error calling close"); || } || } || } || || (b) Here's the result, of in that loop where I call the || BeginScrapeContent method), checking ThreadPool.GetAvailableThreads || each time I perform a new BeginScrapeContent call (again, there are || ever only a max of 8 of these at any time). As you can see the || number of worker threads drops to 0 quite quickly. || || wrkThrds: 25 cpThrds: 25 || wrkThrds: 25 cpThrds: 25 || wrkThrds: 24 cpThrds: 25 || wrkThrds: 24 cpThrds: 25 || wrkThrds: 23 cpThrds: 25 || wrkThrds: 21 cpThrds: 25 || wrkThrds: 19 cpThrds: 25 || wrkThrds: 19 cpThrds: 25 || wrkThrds: 19 cpThrds: 25 || wrkThrds: 17 cpThrds: 25 || wrkThrds: 17 cpThrds: 25 || wrkThrds: 19 cpThrds: 25 || wrkThrds: 17 cpThrds: 25 || wrkThrds: 17 cpThrds: 25 || wrkThrds: 18 cpThrds: 25 || wrkThrds: 17 cpThrds: 25 || wrkThrds: 18 cpThrds: 25 || wrkThrds: 18 cpThrds: 25 || wrkThrds: 17 cpThrds: 25 || wrkThrds: 17 cpThrds: 25 || wrkThrds: 18 cpThrds: 25 || wrkThrds: 17 cpThrds: 25 || wrkThrds: 18 cpThrds: 25 || wrkThrds: 17 cpThrds: 25 || wrkThrds: 17 cpThrds: 25 || wrkThrds: 18 cpThrds: 25 || wrkThrds: 16 cpThrds: 25 || wrkThrds: 17 cpThrds: 25 || wrkThrds: 15 cpThrds: 25 || wrkThrds: 16 cpThrds: 25 || wrkThrds: 16 cpThrds: 25 || wrkThrds: 13 cpThrds: 25 || wrkThrds: 13 cpThrds: 25 || wrkThrds: 12 cpThrds: 25 || wrkThrds: 12 cpThrds: 25 || wrkThrds: 12 cpThrds: 25 || wrkThrds: 12 cpThrds: 25 || wrkThrds: 11 cpThrds: 25 || wrkThrds: 12 cpThrds: 25 || wrkThrds: 12 cpThrds: 25 || wrkThrds: 11 cpThrds: 25 || wrkThrds: 10 cpThrds: 25 || wrkThrds: 9 cpThrds: 25 || wrkThrds: 8 cpThrds: 25 || wrkThrds: 9 cpThrds: 25 || wrkThrds: 9 cpThrds: 25 || wrkThrds: 8 cpThrds: 25 || wrkThrds: 8 cpThrds: 25 || wrkThrds: 7 cpThrds: 25 || wrkThrds: 12 cpThrds: 25 || wrkThrds: 10 cpThrds: 25 || wrkThrds: 10 cpThrds: 25 || wrkThrds: 7 cpThrds: 25 || wrkThrds: 9 cpThrds: 25 || wrkThrds: 8 cpThrds: 25 || wrkThrds: 11 cpThrds: 25 || wrkThrds: 13 cpThrds: 25 || wrkThrds: 13 cpThrds: 25 || wrkThrds: 11 cpThrds: 25 || wrkThrds: 10 cpThrds: 25 || wrkThrds: 11 cpThrds: 25 || wrkThrds: 9 cpThrds: 25 || wrkThrds: 12 cpThrds: 25 || wrkThrds: 11 cpThrds: 25 || wrkThrds: 10 cpThrds: 25 || wrkThrds: 8 cpThrds: 25 || wrkThrds: 7 cpThrds: 25 || wrkThrds: 7 cpThrds: 25 || wrkThrds: 8 cpThrds: 25 || wrkThrds: 8 cpThrds: 25 || wrkThrds: 8 cpThrds: 25 || wrkThrds: 10 cpThrds: 25 || wrkThrds: 14 cpThrds: 25 || wrkThrds: 18 cpThrds: 25 || wrkThrds: 19 cpThrds: 25 || wrkThrds: 17 cpThrds: 25 || wrkThrds: 17 cpThrds: 25 || wrkThrds: 17 cpThrds: 25 || wrkThrds: 15 cpThrds: 25 || wrkThrds: 15 cpThrds: 25 || wrkThrds: 14 cpThrds: 25 || wrkThrds: 14 cpThrds: 25 || wrkThrds: 14 cpThrds: 25 || wrkThrds: 14 cpThrds: 25 || wrkThrds: 11 cpThrds: 25 || wrkThrds: 10 cpThrds: 25 || wrkThrds: 10 cpThrds: 25 || wrkThrds: 10 cpThrds: 25 || wrkThrds: 11 cpThrds: 25 || wrkThrds: 11 cpThrds: 25 || wrkThrds: 11 cpThrds: 25 || wrkThrds: 10 cpThrds: 25 || wrkThrds: 10 cpThrds: 25 || wrkThrds: 8 cpThrds: 25 || wrkThrds: 9 cpThrds: 25 || wrkThrds: 10 cpThrds: 25 || wrkThrds: 5 cpThrds: 25 || wrkThrds: 5 cpThrds: 25 || wrkThrds: 8 cpThrds: 25 || wrkThrds: 7 cpThrds: 25 || wrkThrds: 7 cpThrds: 25 || wrkThrds: 5 cpThrds: 25 || wrkThrds: 6 cpThrds: 25 || wrkThrds: 5 cpThrds: 25 || wrkThrds: 4 cpThrds: 25 || wrkThrds: 3 cpThrds: 25 || wrkThrds: 3 cpThrds: 25 || wrkThrds: 1 cpThrds: 25 || wrkThrds: 0 cpThrds: 25 || || Exception Type: System.InvalidOperationException || Message: There were not enough free threads in the ThreadPool || object to complete the operation. || Stack Trace: || at System.Net.HttpWebRequest.BeginGetResponse(AsyncCa llback || callback, Object state) || at TestApp.Retriever.BeginScrapeContent(ScraperConfig config) || at TestApp.Form1.RetrieveContentStart() || Source: System || Target Site: System.IAsyncResult || BeginGetResponse(System.AsyncCallback, System.Object)
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Dan Battagin |
last post by:
Is there a known bug with the interaction between the HttpWebRequest and the
ThreadPool? I current spawn several HttpWebRequest's using
BeginGetResponse, and they work for a while, using worker...
|
by: Max Adams |
last post by:
Threads and ThreadPool's
If I use a ThreadPool how can I tell when a thead in the threadpool has
exited? I don't want to set a global member variable I would much rather be
able to act on an...
|
by: Trebek |
last post by:
Hello group:
I have a quick question.
Background:
I have an assembly that is responsible for handling our clients' *requests*
(not a webservice/http request per se but our concept of a...
|
by: sfoxover |
last post by:
Hi,
Could someone please give me some suggestions on how to make this class
robust. I need to be able to handle around 20 similtanious requests to
this class which causes a web browser to...
|
by: Craig |
last post by:
Hi,
I have the problem of my ThreadPool running out of threads as a result of
using the HttpWebRequest class. I do use the class asynchronously and I do
call a...
|
by: Basel |
last post by:
Hi All,
I'm opening a number of threads, and each thread generates http
requests using HttpWebRequest.
How to make each thread open only 1 connection ?
I tried to set a unique...
|
by: Sam |
last post by:
Hi All,
I'm trying to write a simple multi-threaded windows service application
using ThreadPool and I'm running into the same problem as described by MS
article:...
|
by: APA |
last post by:
I've seen the MS sample async web request pattern and I ask is it really async if it is using a ManualResetEvent and setting WaitOne()? The
ManualResetEvent object is being declared as a static...
|
by: APA |
last post by:
I've seen the MS sample async web request pattern and I ask is it really async if it is using a ManualResetEvent and setting WaitOne()? The
ManualResetEvent object is being declared as a static...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |