Question Problem to kill process

swapnil

Member
Joined
Nov 25, 2008
Messages
9
Programming Experience
Beginner
Hi

I have developed win 32 application using vs2005 .net framework 2.0
i have a problem with it that whenever i run .exe file of my application when i click Close(X) Button of my system form the form will get close but the process will not get terminated .
From task manager i have to do manually end process .
i want to know how to write code for it and what event or settings i have to do in my application.
 
Unless your executable is corrupt in some way the only reason that this would happen is that you have another thread running that is preventing the process from exiting. Are you, explicitly or implicitly, creating one or more threads in your app?
 
Unless your executable is corrupt in some way the only reason that this would happen is that you have another thread running that is preventing the process from exiting. Are you, explicitly or implicitly, creating one or more threads in your app?

thanks for reply

NO i am not using any thread concept

i my application contains around 14 forms...

when i run each form individually by setting start up form at that time it doesn't happened , that means if i set satartup form as form1 and build solution .. then when i run my .exe file and close the form1 then process get end automatically , but when i go to next form using next button which takes me to next form and then if i close my application then process doesn't teminate only form get closed.

i am using this code for moving from one form to another

Dim obj as New Form1
obj.Show()
Me.Close() or Me.Hide
 
There is a difference between "Me.Close() or Me.Hide". Windows Application has a project setting "shutdown mode" that is set to "when main form closes" by default. If you hide main form and close second form then app will not close, while if you close main form then app closes. You can change shutdown mode to "when last form closes" if you want to keep various forms open but perhaps not main form.
 
To kill the process.

you could also use the command Application.Exit() to exit from the app. This will make sure that the process has terminated, and you can call this from any form in your application.
 
There is a difference between "Me.Close() or Me.Hide". Windows Application has a project setting "shutdown mode" that is set to "when main form closes" by default. If you hide main form and close second form then app will not close, while if you close main form then app closes. You can change shutdown mode to "when last form closes" if you want to keep various forms open but perhaps not main form.

Thank you for reply

there is no last form in my application user can close application in any from by clicking [X] button of form
and i am using Me..Hide() Only for my Start up window (Main window) if i write Me.Close() then hole application will get terminat thats why for only first form a i am using Me.Hide() and for rest of all i am using Me.close()

One more thing is that if i go to next form from main form and comeback again to first form by clicking back button and then if i close my first form then still the process doesn't get terminated.....
 
you could also use the command Application.Exit() to exit from the app. This will make sure that the process has terminated, and you can call this from any form in your application.

thank you for reply

i want to close my hole application to terminate by clicking [X] (Close) Button Top Right of any Form in my application
so pleas tell my how to handle [X] button of Form event in my code ...
 
That's what "when last form closes" means. It means that application closes when the last one of any open forms is closed. If you hide main form it is not closed.
 
Start the app from Sub main and have it run in a loop as long as a form exists, when all forms are closed (never hide a form) the loop in sub main should exit and your app will end
 
Back
Top