From: Tony Johansson on
Hi!

I have check that the default available threads in the ThreadPool is 250 so
I made this small check just to see what happen what I run out of threads.

I noticed that I didn't get any kind of error such as execption or things
like that.
The only thing that happen is that no more threads is being used because
there is no one left.

This seems like a strange situation that I don't get an exeption ?
Give me a comment about this.

static void Main(string[] args)
{
for (int i = 0; i < 260; i++)
{
ThreadPool.QueueUserWorkItem(new WaitCallback(DoWork), i);
}
}

private static void DoWork(object o)
{
Console.WriteLine("Number = {0}",(int)o);
Thread.Sleep(9999999);
}

//Tony


From: Alberto Poblacion on
"Tony Johansson" <johansson.andersson(a)telia.com> wrote in message
news:%23dCKY%23n8KHA.5476(a)TK2MSFTNGP06.phx.gbl...
> I have check that the default available threads in the ThreadPool is 250
> so
> I made this small check just to see what happen what I run out of threads.
>
> I noticed that I didn't get any kind of error such as execption or things
> like that.
> The only thing that happen is that no more threads is being used because
> there is no one left.
>
> This seems like a strange situation that I don't get an exeption ?
> [...]
> ThreadPool.QueueUserWorkItem(new WaitCallback(DoWork), i);

Look carefully at the name of the method you are calling:
QUEUEuserworkitem. Doesn't it suggest something? It is queuing the request
so that it will be allocated a thread when one becomes available in the
ThreadPool.