palaga,
Unfortunately, no, there is not. However, it would be rather simple to
write a little wrapper delegate that will do this (instead of injecting it
into your code in every delegate).
The one thing that you have to worry about is handle management. If you
have a large number of items in the thread pool, then you can easily create
too many events which can have an impact on performance.
Check out the .NET Matters section of the October 2004 issue of MSDN
magazine, specifically, the first question. It addresses your exact
problem, as well as provides a good solution. You can find it at (watch for
line wrap):
http://msdn.microsoft.com/msdnmag/is...10/NetMatters/
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
-
mv*@spam.guard.caspershouse.com
"palaga" <fb*********@ubisoft.fr> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
hi
I'm using QueueUserWorkItem to execute a bunch of tasks using the thread
pool. Once started, I would like to wait for all of them to finish, using
something like WaitAll. Is there a way I can know when a thread pool
workItem has finished executing ? (My only solution at this time is to use
an autoreset event that is reset before I enqueue the workItem, that is
set
by my workitem when it finishes.). Is there a built-in mechanism in the
thread pool to avoid using my own autoresetEvent ?
thanks