How to enforce only 1 instance can be running at the same time?

  • Thread starter Thread starter babylon
  • Start date Start date
B

babylon

e.g. we can only start one instance of Outlook Express (vs multiple instance
of IE)
How should this be implmented in winform?

thx
 
I run my app from a sub main and this is how I was shown to do it.

Imports System.Threading

Private m As Mutex
Sub Main()
Dim first As Boolean
m = New Mutex(True, "Your App Name Here", first)
If Not (first) Then
MessageBox.Show("The Application is already running.")
AppRunning()
Exit Sub
End If


Private Sub AppRunning()
Application.Exit()
End Sub
 
it works~!
cool.

so the name of the mutex is system-wide, right?

thx
 
System wide meaning on a single computer... Yes. Network wide of web
wide... I don't think so.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top