[Mono-list] Couldn't create thread exception for ThreadPool.QueueUserWorkItem

Gonzalo Paniagua Javier gonzalo.mono at gmail.com
Wed Jul 8 10:35:31 EDT 2009

On Wed, 2009-07-08 at 09:08 -0300, Arthur Valadares wrote:
> Hi Gonzalo, thanks for the reply,
> I know there is a limit, but by reading the MSDN page about
> QueueUserWorkItem, it was suggested that if you request a thread beyond
> the ThreadPool limit, it would wait until a thread is freed to give it
> to the request, and not crash. The exception doens't even come from the
> ThreadPool,but from the ExecutionEngineException. That's what led me to
> believe it might not be expected behavior.
> It's a callback that keeps firing and it's job is to send an image.
> Since sending an image can take a while, it stays alive for some time. I
> already did some work to do a consumer-producer queue, but I would like
> to avoid it if possible, since my application is being built to stress
> performance in exactly this point.

You can send the image in chunks using any of the Socket or
HttpWebRequest BeginSend/BeginWrite and once your callback is called
indicating that sending the chunk succeeded, proceed with the next one.
No need to keep a thread waiting for all the writes to finish...


More information about the Mono-list mailing list