Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Closing Application Properly

Closing Application Properly

Scheduled Pinned Locked Moved C#
questionhelpworkspace
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Dwayner79
    wrote on last edited by
    #1

    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

    S 1 Reply Last reply
    0
    • D Dwayner79

      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

      S Offline
      S Offline
      S Senthil Kumar
      wrote on last edited by
      #2

      Can'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

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups