G
Guest
Hi,
I have a .NET class which uses the .NET threadpool (using QueueUserWorkItem)
to create about 8 threads, which do some work while the parent thread waits
for them all to complete, which works fine when referenced from a normal EXE.
When I reference this DLL in a webservice however, the threads seem to be
created one by one in order, rather than at the same time - it is as if there
is only one available thread in the ThreadPool and the rest are being queued.
I can see this as I have code that writes the execution order to the event
log. In the version referenced from the EXE the order they return is in
keeping with what I would expect based on how long each takes i.e., the
fastest returns first, the slowest last. From the webservice, they appear in
the other they are created. I changed the first thread to sleep for 10
seconds, and it in the webservice it still finished first. The same code from
the EXE and it finished last, as you would expect.
Any ideas on why this is happening as the performance loss when I use this
in the webservice is massive. I read that ASP.Net (or IIS) also uses the
ThreadPool, but the system isn't even loaded. I called GetAvailableThreads()
which returned 50.
Thanks,
DAve
I have a .NET class which uses the .NET threadpool (using QueueUserWorkItem)
to create about 8 threads, which do some work while the parent thread waits
for them all to complete, which works fine when referenced from a normal EXE.
When I reference this DLL in a webservice however, the threads seem to be
created one by one in order, rather than at the same time - it is as if there
is only one available thread in the ThreadPool and the rest are being queued.
I can see this as I have code that writes the execution order to the event
log. In the version referenced from the EXE the order they return is in
keeping with what I would expect based on how long each takes i.e., the
fastest returns first, the slowest last. From the webservice, they appear in
the other they are created. I changed the first thread to sleep for 10
seconds, and it in the webservice it still finished first. The same code from
the EXE and it finished last, as you would expect.
Any ideas on why this is happening as the performance loss when I use this
in the webservice is massive. I read that ASP.Net (or IIS) also uses the
ThreadPool, but the system isn't even loaded. I called GetAvailableThreads()
which returned 50.
Thanks,
DAve