W
wg
I am attempting to prevent a second instance of my application from
starting. I have the following code at the beginning of Form_Load
If Process.GetProcessesByName(Process.GetCurrentProcess.ProcessName).Length
Application.Exit()
Logger.LogMessage("FormLoad", "Second instance of application attempted")
End If
I know that it is going into the If-Then condition because it writes to my
logger. But the 2nd application still starts up. Should I set the startup to
Sub Main? Or can anyone offer suggestions?
Thanks
wg
starting. I have the following code at the beginning of Form_Load
If Process.GetProcessesByName(Process.GetCurrentProcess.ProcessName).Length
Me.Close()1 Then
Application.Exit()
Logger.LogMessage("FormLoad", "Second instance of application attempted")
End If
I know that it is going into the If-Then condition because it writes to my
logger. But the 2nd application still starts up. Should I set the startup to
Sub Main? Or can anyone offer suggestions?
Thanks
wg