Ole wrote:
The Application.Exit (called from a worker thread) method doesn't cause the
OnClosing event handler to be run - is that a default behaviour??? If so -
what should I do to properly close all threads etc.
Thanks
Ole
This is the default behavior:
http://msdn2.microsoft.com/en-us/lib...orm.close.aspx http://blogs.msdn.com/tom_krueger/ar...24/379678.aspx
You can hook the Application.ApplicationExit event or call the Close()
method of your main form. This has the advantage that all expected
events are raised
If you decide to call the close method, remember to invoke the call when
you are not in the Gui Thread:
private delegate void NullaryFunction();
private void CloseForm()
{
Debug.Assert(mainForm != null && mainForm.IsHandleCreated);
if (mainForm.InvokeRequired)
mainForm.BeginInvoke(new NullaryFunction(mainForm.Close));
else
mainForm.Close();
}
HTH,
Andy
--
You can email me directly by removing the NOSPAm below
xm**********@gmxNOSPAm.netNOSPAm