laroberts Posted July 1, 2005 Posted July 1, 2005 (edited) I have noticed with my VB.NET program that when I click on the X in the right corner of the window to close the program it is still running as a process in Windows. How do I stop this from taking place? When I push the X I want it to clear out of Windows completely. I know you can use application.exit to terminate everything but that does not help if somebody hits the X in the right corner. Thank you Edited July 1, 2005 by laroberts Quote
Administrators PlausiblyDamp Posted July 1, 2005 Administrators Posted July 1, 2005 If you application isn't exiting it usually means you have not closed down all forms you opened or threads you started. Are you providing an exit button for the users? If so how are you handling the shutdown there? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
laroberts Posted July 1, 2005 Author Posted July 1, 2005 No I can shutdown the application just fine if I use a button for it. Its when a user pushes the X in the right hand corner. I do not want to shutoff the controls up there so there must be a way to take care of that when they push it. Quote
jmcilhinney Posted July 1, 2005 Posted July 1, 2005 What do you do when they use your Exit button/menu option? Do you destroy any objects that are not being disposed properly the other way? Quote
Simcoder Posted July 5, 2005 Posted July 5, 2005 You probably still have some hidden forms running or something like that. If you want to terminate the application when the user clicks the "X", then you might want to do an Application.exit or something similar on the closing event for that form. You can even give the user a messagebox first or just do an Application.exit on the form closing event. Private Sub frmMain_Closing(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing Dim Dgr As DialogResult Dgr = MessageBox.Show("Do You Really Want To Exit?", "Confirm Exit", MessageBoxButtons.YesNo, MessageBoxIcon.Question) If Dgr = DialogResult.Yes Then Application.Exit() Else e.Cancel = True End If End Sub -=Simcoder=- Quote Whatever thy hand findest to do, do it with all thy heart - Jesus
Administrators PlausiblyDamp Posted July 5, 2005 Administrators Posted July 5, 2005 Application.Exit will not call any code in a form's Closed or Closing events though - if you have validation / save logic in these events then it will be skipped. Generally it is better to close down resources when you have finished with them - if you ever get to a point when you have resources allocated that you have forgotten about then your code needs revising. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.