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. Visual Basic
  4. How to quit application completely?

How to quit application completely?

Scheduled Pinned Locked Moved Visual Basic
csharphelptutorialquestion
9 Posts 5 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.
  • R Offline
    R Offline
    re infecta
    wrote on last edited by
    #1

    I'm writing an app in VB.net with .NET 2. The application has a main form plus two other forms. When I click Exit-button on the main form, I call Me.Close(). After that MainForm_Closing routine handles the shut-down procedures. Ultimately I call Application.Exit(). The problem is that although the main form dissapears, application (.exe) keeps reserving system resources (95%!). How to close the application completely? I think the problem is that the two other forms are not closed, but hidden.

    F D 2 Replies Last reply
    0
    • R re infecta

      I'm writing an app in VB.net with .NET 2. The application has a main form plus two other forms. When I click Exit-button on the main form, I call Me.Close(). After that MainForm_Closing routine handles the shut-down procedures. Ultimately I call Application.Exit(). The problem is that although the main form dissapears, application (.exe) keeps reserving system resources (95%!). How to close the application completely? I think the problem is that the two other forms are not closed, but hidden.

      F Offline
      F Offline
      FeRtoll
      wrote on last edited by
      #2

      on your form put button "Exit" in exit buton type like this: Private Sub cmdEnd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdEnd.Click Me.Close Me.Dispose End Sub and if you have to save anny data before closing, do it in "Form close event" Private Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing 'Saving data System.IO.File.Create(Application.StartUpPath+"\data.ini") End Sub ------------------------------------------------------------------ Just be shure that u dont type on some other button which is suposed to end aplication that you type "End". Allways use "Me.Close" ------------------------------------------------------------------ Hope it helps! :->

      FeRtoll Software.net ------------ E-Mail me WebPage

      1 Reply Last reply
      0
      • R re infecta

        I'm writing an app in VB.net with .NET 2. The application has a main form plus two other forms. When I click Exit-button on the main form, I call Me.Close(). After that MainForm_Closing routine handles the shut-down procedures. Ultimately I call Application.Exit(). The problem is that although the main form dissapears, application (.exe) keeps reserving system resources (95%!). How to close the application completely? I think the problem is that the two other forms are not closed, but hidden.

        D Offline
        D Offline
        Dave Kreskowiak
        wrote on last edited by
        #3

        Are you holding an unmanaged resources open that you should have Disposed? Started any threads that you didn't stop? Used a COM component that you didn't shutdown?

        Dave Kreskowiak Microsoft MVP - Visual Basic

        H R 2 Replies Last reply
        0
        • D Dave Kreskowiak

          Are you holding an unmanaged resources open that you should have Disposed? Started any threads that you didn't stop? Used a COM component that you didn't shutdown?

          Dave Kreskowiak Microsoft MVP - Visual Basic

          H Offline
          H Offline
          hey_ian3
          wrote on last edited by
          #4

          Usually Application.Exit() is enough to close the process completely. If not, try to close all other forums with the .Close method.

          D 1 Reply Last reply
          0
          • H hey_ian3

            Usually Application.Exit() is enough to close the process completely. If not, try to close all other forums with the .Close method.

            D Offline
            D Offline
            Dave Kreskowiak
            wrote on last edited by
            #5

            Not exactly. If you leave running resources, like a thread not set as Background, it'll stay running and visible in TaskManager, regardless of how you exit the app. If you don't do anything like this, leaving unmanaged resources orphaned, then Application.Exit will do what you expect it to.

            Dave Kreskowiak Microsoft MVP - Visual Basic

            1 Reply Last reply
            0
            • D Dave Kreskowiak

              Are you holding an unmanaged resources open that you should have Disposed? Started any threads that you didn't stop? Used a COM component that you didn't shutdown?

              Dave Kreskowiak Microsoft MVP - Visual Basic

              R Offline
              R Offline
              re infecta
              wrote on last edited by
              #6

              My application is very simple, so I _think_ I haven't open any additional resources. MidiOutOpen is called when main form is loaded, but I close that in the MainForm_closing event. I'm a beginner and I don't know what are threads. Can you please explain me? Still, I can see that two threads are left open even though application should have been shutdown. How to close all threads? Are active timer components threads? What does the "Me.Dispose" command do? It didn't help though.

              D 1 Reply Last reply
              0
              • R re infecta

                My application is very simple, so I _think_ I haven't open any additional resources. MidiOutOpen is called when main form is loaded, but I close that in the MainForm_closing event. I'm a beginner and I don't know what are threads. Can you please explain me? Still, I can see that two threads are left open even though application should have been shutdown. How to close all threads? Are active timer components threads? What does the "Me.Dispose" command do? It didn't help though.

                D Offline
                D Offline
                Dave Kreskowiak
                wrote on last edited by
                #7

                re infecta wrote:

                My application is very simple, so I _think_ I haven't open any additional resources.

                Even the simplest of applications can have the biggrest of problems. Since you're using a Midi library, you're more than likely using unmanaged resources.

                re infecta wrote:

                MidiOutOpen is called when main form is loaded, but I close that in the MainForm_closing event.

                You might want to check with the documentation of this library to see if your shutting it down properly. You can Open and Close it, but is this the correct procedure for using it?? DOn't worry about threads. If you didn't launch any, and you'll know if you did, you don't have the responsibility of managing them. Don't do Me.Dispose. That tell's the current object, more than likely your form, to kill itself! This MAY be the cause of your problem...

                Dave Kreskowiak Microsoft MVP - Visual Basic

                W 1 Reply Last reply
                0
                • D Dave Kreskowiak

                  re infecta wrote:

                  My application is very simple, so I _think_ I haven't open any additional resources.

                  Even the simplest of applications can have the biggrest of problems. Since you're using a Midi library, you're more than likely using unmanaged resources.

                  re infecta wrote:

                  MidiOutOpen is called when main form is loaded, but I close that in the MainForm_closing event.

                  You might want to check with the documentation of this library to see if your shutting it down properly. You can Open and Close it, but is this the correct procedure for using it?? DOn't worry about threads. If you didn't launch any, and you'll know if you did, you don't have the responsibility of managing them. Don't do Me.Dispose. That tell's the current object, more than likely your form, to kill itself! This MAY be the cause of your problem...

                  Dave Kreskowiak Microsoft MVP - Visual Basic

                  W Offline
                  W Offline
                  WestSideRailways
                  wrote on last edited by
                  #8

                  What is the difference between the following :- Application.Exit() Me.Close End in ending a program.:confused:

                  D 1 Reply Last reply
                  0
                  • W WestSideRailways

                    What is the difference between the following :- Application.Exit() Me.Close End in ending a program.:confused:

                    D Offline
                    D Offline
                    Dave Kreskowiak
                    wrote on last edited by
                    #9

                    Application.Exit()[^] Form.Close()[^] Visual Basic.NET keyword End[^]

                    Dave Kreskowiak Microsoft MVP - Visual Basic

                    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