Hi there Alex,
I'm looking into this thanks. What I can't readily see at the moment is how the caller of BeginInvoke can actually terminate the worker process. Say for example the worker process is manipulating hardware, it's not enough to return and ignore the process if the results are undesired - the activity has to stop punctually.
What I'm aiming for is how to abort the worker thread, and ideally be able to catch the ThreadAbortException in the worker thread.
Main Topics
Browse All Topics





by: AlexFMPosted on 2007-01-08 at 11:41:32ID: 18269701
Do you need "Fire and forget" pattern - call BeginInvoke and immediately continue? In this case use this way: /csharp/de legate_bed time.asp
le. This is what makes invoking synchronous. However, this is the place where you can wait for two events: AsyncWaitHandle and thread stop event. If stop event is signaled, exit thread function - thread is responsive.
http://www.codeproject.com
See code sample "Async Notification: Delegates".
If you need to call EndInvoke syncronously, you can do this immediately after BeginInvoke call. Notice that EndInvoke returns immediately without waiting delegate to be handled, this doesn't prevent thread to be responsive for stop request. To wait when delegate is handled by client, you need to wait for IAsyncResult.AsyncWaitHand