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. Application.Exit();, Environment.Exit(0); or this.Close();

Application.Exit();, Environment.Exit(0); or this.Close();

Scheduled Pinned Locked Moved C#
workspace
4 Posts 3 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.
  • V Offline
    V Offline
    Vandretta
    wrote on last edited by
    #1

    I just wanted to know which one I should use. I have looked at the MSDN articles and have only found rigorous descriptions of each one but none of them give comparisons to the others. p.s. this is my first post, if I have done anything wrong please feel free to tell me. the code I have is:

    private void exitToolStripMenuItem_Click(object sender, EventArgs e)
    {
    GC.Collect();
    Environment.Exit(0);//Or Application.Exit(); or this.Close(); I'm not sure
    }

    G P 2 Replies Last reply
    0
    • V Vandretta

      I just wanted to know which one I should use. I have looked at the MSDN articles and have only found rigorous descriptions of each one but none of them give comparisons to the others. p.s. this is my first post, if I have done anything wrong please feel free to tell me. the code I have is:

      private void exitToolStripMenuItem_Click(object sender, EventArgs e)
      {
      GC.Collect();
      Environment.Exit(0);//Or Application.Exit(); or this.Close(); I'm not sure
      }

      G Offline
      G Offline
      Giorgi Dalakishvili
      wrote on last edited by
      #2

      Close() just closes the form, it doesn't necessarily cause exit. Here is comparison of Application.Exit and Environment.Exit: Application.Exit vs. Environment.Exit[^]

      Giorgi Dalakishvili #region signature my articles #endregion

      1 Reply Last reply
      0
      • V Vandretta

        I just wanted to know which one I should use. I have looked at the MSDN articles and have only found rigorous descriptions of each one but none of them give comparisons to the others. p.s. this is my first post, if I have done anything wrong please feel free to tell me. the code I have is:

        private void exitToolStripMenuItem_Click(object sender, EventArgs e)
        {
        GC.Collect();
        Environment.Exit(0);//Or Application.Exit(); or this.Close(); I'm not sure
        }

        P Offline
        P Offline
        PIEBALDconsult
        wrote on last edited by
        #3

        this.Close();

        V 1 Reply Last reply
        0
        • P PIEBALDconsult

          this.Close();

          V Offline
          V Offline
          Vandretta
          wrote on last edited by
          #4

          Ok, thankyou guys.

          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