Right, my application occassionally kicks off a background thread that does some stuff.
As its doing its stuff it also updates a progress bar on the main window. It does this by calling Invoke to get the main thread to update the interface.
When the user closes the application, I want to wait until all the background threads are finished before closing the form. In the form closing event I have something like
while ( this._Queue.Count > 0 )
Application.DoEvents ();
But this does not work!!
The background thread is getting stuck on the Invoke call. The main thread continues to loop around calling its DoEvents, which I thought would be all it needed to do to pick up and process its invokes. But it isnt doing this...
Why not!?!