Hi guys, im trying to make a program that will start a Process and then handle the Process's Exited event and do some code when the application is exited. I dont need to display a form for this so i decided i'd make a formless app. This is my code:
My problem is, the application exits itself as soon as the Main Sub is exited. Is there anyway to prevent this? or another way of doing my code alltogether?
Thanks, Dan
Visual Basic:
Imports System.Diagnostics
Public Class Test
Shared WithEvents P As Process
Shared args() As String
Shared Sub Main()
args = System.Environment.GetCommandLineArgs
P = New Process
P = Process.Start(args(1))
End Sub
Private Shared Sub P_Exited(ByVal sender As Object, ByVal e As System.EventArgs) Handles P.Exited
Process.Start(args(2))
End Sub
End Class
My problem is, the application exits itself as soon as the Main Sub is exited. Is there anyway to prevent this? or another way of doing my code alltogether?
Thanks, Dan