all groups > vb.net controls > july 2004 >
You're in the

vb.net controls

group:

Newbie - Can't Kill Program



Newbie - Can't Kill Program google.4.oracle NO[at]SPAM xoxy.net
7/23/2004 11:29:16 AM
vb.net controls: I wrote a simple VB program that runs.
When I click on the close button in the upper right hand corner
of the main windows, the program closes. Or at least it appears to.
The form closes on the the screen.
If I look in the Task List manager, I can still see my app TTEST.EXE
running.
If I start it up again, I get a second instance of TTEST.EXE running.

I thought that if I call Application.Exit this would kill the task but
it does not.
How do I properly close my program so that it kills the task?

Here is my startup code.

Public Class Startup
Private Shared m_MainForm As MainTabForm

' This class is created so that I take control of the Mainform
from VB.net
' This gives me global access to all members of the form

Public Shared ReadOnly Property MainForm() As MainTabForm
Get
Return m_MainForm
End Get
End Property

Public Shared Sub Main()
m_MainForm = New MainTabForm
Application.Run(m_MainForm) ' Run my MainForm Windows
m_MainForm.Close()
Application.Exit()
End Sub

Re: Newbie - Can't Kill Program Samuel L Matzen
7/24/2004 4:35:31 PM
Bob,

delcare the m_MainForm WithEvents. Something like:

Private Shared WithEvents m_MainForm as MainTabForm.

Instead of doing the Application.Run, I just invoke the ShowDialog method of
m_MainForm.

In the m_MainForm Closed event invoke Application.Exit()

This works for me.

-Sam matzen



[quoted text, click to view]

AddThis Social Bookmark Button