Kill Thread : Asynchronous Function Call

Pradip

New member
Joined
Sep 20, 2008
Messages
3
Programming Experience
1-3
I called a function with BeginInvoke. A new seperate thread created. But I couldn't get sure wheteher the thread gets killed after the execution is over or not. If not, what should be the way to kill it. Is it EndInvoke? If yes, how should I apply EndInvoke?
 
Last edited:
Delegate.BeginInvoke must be coupled with EndInvoke, see article Calling Synchronous Methods Asynchronously for different ways of doing that. As the article explains EndInvoke is a blocking call that executes when worker thread is finished. I'd like to add that the article section about using a callback is missing the fact that IAsyncResult can be cast to a AsyncResult and the caller AsyncDelegate be retrieved from there. Threadpool threads can't be aborted, but you can use a variable that the worker polls to see if it should stop working.
 
Back
Top