Closing Application Properly
-
I am having trouble closing my application properly. I have a MDI environment. Each child can have a usercontrol loaded. I have in my Parent the following. All is psudo-code.
ExitApp() { if(childForm != null) { childForm.ExitFunction(); } else { App.Close(); } }
in Childform,ExitFunction() { if(userControl != null) { userControl.ExitFunction(); } else { //This is the issue??? See below } }
A similar function in the userControl. I had called a event handler that relaunched the ExitApp function. But obviously, the childform is not unloaded, so this just loops like crazy. How can I verify that the child is unloaded prior to Re-launching the Exit app function. Thanks in advance... ***************** "We need to apply 21st-century information technology to the health care field. We need to have our medical records put on the I.T." —GW -
I am having trouble closing my application properly. I have a MDI environment. Each child can have a usercontrol loaded. I have in my Parent the following. All is psudo-code.
ExitApp() { if(childForm != null) { childForm.ExitFunction(); } else { App.Close(); } }
in Childform,ExitFunction() { if(userControl != null) { userControl.ExitFunction(); } else { //This is the issue??? See below } }
A similar function in the userControl. I had called a event handler that relaunched the ExitApp function. But obviously, the childform is not unloaded, so this just loops like crazy. How can I verify that the child is unloaded prior to Re-launching the Exit app function. Thanks in advance... ***************** "We need to apply 21st-century information technology to the health care field. We need to have our medical records put on the I.T." —GWCan't you avoid calling ExitApp recursively? If not, I think the only way is to add a flag that is set to true when the "else" part executes for the first time and then conditionally skip execution from the next time.
ExitFunction()
{
if (isRecursive)
return;
else
isRecursive = true;
if(userControl != null)
{
userControl.ExitFunction();
}
else
{
//This is the issue??? See below
}
}Regards Senthil _____________________________ My Blog | My Articles | WinMacro