In VB, you can set this at the project level (Properties> General) for Winforms projects.
In C #, you can use code like this .. course conversion is required.
Dim tGrantedMutexOwnership As Boolean = False Dim tSingleInstanceMutex As Mutex = New Mutex(True, "MUTEX NAME HERE", tGrantedMutexOwnership) If Not tGrantedMutexOwnership Then ' ' Application is already running, so shut down this instance ' Else ' ' No other instances are running ' End If
Oops, I forgot to mention that you will need to place GC.KeepAlive(tSingleInstanceMutex) after calling Application.Run ()
source share