Imports System.Threading
Module Module1
Dim mutexOk As Boolean
Dim m As Mutex
Sub Main()
m = New Mutex(True, "MyMutexName", mutexOk)
If Not mutexOk Then
MsgBox("Another instance already running, quitting this one.")
Return
End If
MsgBox("First Instance")
GC.KeepAlive(m)
End Sub
End Module
|