Hi, how can I raise an event after a thread has just ended?
Thanks
Printable View
Hi, how can I raise an event after a thread has just ended?
Thanks
The BackGroundWorker will do this automatically, so I assume that you are talking about a plain thread. One option would be to switch to using the BackGroundWorker so that you get the event, and the other option is to raise the event as the final act of the thread.
For that second option, I save the SynchronizationContext of the UI thread, then Post a call to a sub in UI context that raises the event. By doing this, the event is raised in the UI thread, not in the background thread. If you want more information on that, search for my name and SynchronizationContext, as I have posted examples a couple of times. However, the BackGroundWorker object sounds like it may be more appropriate for you.
OK thanks