Hi SSonnenwald,
IMHO there is now way to achieve that using ThreadPool directly.
However you can get this wroking in the way you want by calling a delegate
asynchronously.
Let's for the sake of this example assume the method you want to execute in
the thread pool has the following prototype
void Foo(int param);
1. Create a delagate object for the method you want to execute in a thread
from the thread pool.
delegate void FooDelegate(int param);
FooDelegate del = new FooDelegate(Foo );
2. Call the deleagte asynchronously and pass an AsyncCallback delegate
representing the method that will be executed when the thread finishes its
work.
del.BeginInvoke (100, new AsyncCallback(M yCallback), del);
The Foo methods will be executed in the thread from the thread pool and the
method MyCallback will be executed when the thread finishes its work.
The last parameter of the BeginInvoke is called 'AsyncState'. You can pass
any object you want and this object will be passed in turn to the MyCallback
method. Usually you pass the delegate object which BeginInvoke method you
called in order to call EndInvoke when the works done.
AsyncCallback delegate is declared as
public delegate void AsyncCallback(I AsyncResult ar);
To get the AsyncState object from inside the callback method you read
IAsyncResult.As yncState
property.
--
HTH
B\rgds
Stoitcho Goutsev (100) [C# MVP]
"SSonnenwal d" <SS*********@ya hoo.com> wrote in message
news:a0******** *************** ***@posting.goo gle.com...
I have created a piece of code that uses a ThreadPool class and the
QueueUserWorkIt em method to add items to the the ThreadPool. What
would seem to be simple I just can not figure out how to tell if all
of the threads in the threadpool that I queued have completed. Does
anyone have a way???? Any help would be appreciated.
Thanks,
Scott