How to quit application completely?
-
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.
-
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.
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
-
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.
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
-
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
-
Usually Application.Exit() is enough to close the process completely. If not, try to close all other forums with the .Close method.
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
-
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
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.
-
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.
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
-
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
What is the difference between the following :- Application.Exit() Me.Close End in ending a program.:confused:
-
What is the difference between the following :- Application.Exit() Me.Close End in ending a program.:confused:
Application.Exit()[^] Form.Close()[^] Visual Basic.NET keyword End[^]
Dave Kreskowiak Microsoft MVP - Visual Basic