M
Michael
In VB.NET, how do you check to see if an instance of your
application is already running?
application is already running?
* "Michael said:In VB.NET, how do you check to see if an instance of your
application is already running?
* Tom Shelton said:
That is a good way to do it if you need to get a bit of information
about the previous proces - especially if your going to pass information
to it. But if you have simple needs, like all you care about is if it
is running - here is an alternate method. [...]
Dim mut As New Mutex(True, "myuniquemutexname", owned)
* Tom Shelton said:
That is a good way to do it if you need to get a bit of information
about the previous proces - especially if your going to pass information
to it. But if you have simple needs, like all you care about is if it
is running - here is an alternate method. [...]
Dim mut As New Mutex(True, "myuniquemutexname", owned)
I remember I posted a link to a sample like this.
;-)
Michael said:In VB.NET, how do you check to see if an instance of your
application is already running?
* Tom Shelton said:That is a good way to do it if you need to get a bit of information
about the previous proces - especially if your going to pass information
to it. But if you have simple needs, like all you care about is if it
is running - here is an alternate method. [...]
Dim mut As New Mutex(True, "myuniquemutexname", owned)
I remember I posted a link to a sample like this.
;-)
Crap! I hate when I don't scroll down! Sorry. I wasn't trying to take
away from your post Herfried... I was just trying to provide some
additional information (which I see was there, boy do I feel dumb
* "George Shubin said:Here's another way: (watch out for word-wrap)
'This is the application's startup routine
'Check to see if a previous instance of this application is running already
If
(UBound(Diagnostics.Process.GetProcessesByName(Diagnostics.Process.GetCurren
tProcess.ProcessName)) > 0) Then
MessageBox.Show("Already running on your system.", AppDesc,
MessageBoxButtons.OK, MessageBoxIcon.Information)
Exit Sub
End If
* "Fergus Cooney said:What's the difference between an application name and a process name?
Hi Tom, Herfried,
Lazy, he calls him. What happened to forgetful, distracted, unobservant,
hasty?
I prefer hasty myself - as in keen to get back to post a solution ;-).
Actually there is a difference between your methods.
Dim FirstTimeIn As Boolean
Dim mut As New Mutex(True, "myuniquemutexname", FirstTimeIn)
If FirstTimeIn Then
versus
Dim mut As Mutex = New Mutex(False, "myuniquemutexname")
If mut.WaitOne(10, False) Then
Any advantages of one over the other?
Regards,
Fergus
* "Fergus Cooney said:Thanks, that's what I believed, but I thought I might have missed
soimething.
I think it is unlikely in general to have the clash that you mention, but
I can see it happening with different versions of the same software or
utilities such as 'Calculator'.
* "Fergus Cooney said:Are you related to the Herfried who I've been mud-wrestling with over in
the other threads?
You seem like such a nice chap!! ;-)