UncleRonin
Well-known member
Okay, this is the situation...
I have an application that has a GUI and a couple of threads that run in the background. Every now and then one of the threads has to update a GUI control so I call Invoke and update it. When the application closes the threads must finish their execution cycle so I force the application to wait before closing (I have Closing and a Processing variables so that while the application is not Closing the threads will continue to execute and while Processing the application will not close).
The interesting thing now is that if the application is closing and a thread is busy executing and calls Invoke, the application hangs. If I call BeginInvoke everything is 'okay' and the thread stops executing and the application closes happily. My question is this: what exactly happens with Invoke when an application is closing? Obviously it's blocking somewhere inside the whole Invoke business and not returning so the thread ends up in stasis... but why??
What happens to the application event queue when it starts closing? What happens inside Invoke? Why is the weather so terrible today!?!
I have an application that has a GUI and a couple of threads that run in the background. Every now and then one of the threads has to update a GUI control so I call Invoke and update it. When the application closes the threads must finish their execution cycle so I force the application to wait before closing (I have Closing and a Processing variables so that while the application is not Closing the threads will continue to execute and while Processing the application will not close).
The interesting thing now is that if the application is closing and a thread is busy executing and calls Invoke, the application hangs. If I call BeginInvoke everything is 'okay' and the thread stops executing and the application closes happily. My question is this: what exactly happens with Invoke when an application is closing? Obviously it's blocking somewhere inside the whole Invoke business and not returning so the thread ends up in stasis... but why??
What happens to the application event queue when it starts closing? What happens inside Invoke? Why is the weather so terrible today!?!