PC Review


Reply
Thread Tools Rate Thread

Checking if running

 
 
MadCrazyNewbie
Guest
Posts: n/a
 
      13th Apr 2004
Hey Group,

How would I check if my Application is running on a local PC and if it is
throw a message to say its already running and quit the the second instance?

Many Thanks
MCN


 
Reply With Quote
 
 
 
 
Cor Ligthert
Guest
Posts: n/a
 
      13th Apr 2004
Hi MS,

This is the very simple solution from this.
\\\
Private mut As New Threading.Mutex(True, "myProg", mutCreated)
)
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
If Not mutCreated Then Me.Close()
///
But remember that when you use this, and there can be a complete other
program with the same name as yours, that program can also not start.

Better
Single instance mostly C# code
http://msdn.microsoft.com/library/de...eaworapps1.asp

I hope this helps?

Cor


 
Reply With Quote
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      13th Apr 2004
* "MadCrazyNewbie" <(E-Mail Removed)> scripsit:
> How would I check if my Application is running on a local PC and if it is
> throw a message to say its already running and quit the the second instance?


For example, in your 'Sub Main':

\\\
Dim m As Mutex = _
New Mutex(False, "{11C92606-65D9-4df2-9AEA-B6A4DA91BCE2}")
If m.WaitOne(10, False) Then
Application.Run(New Form1())
m.ReleaseMutex()
Else
MessageBox.Show("Anwendung wird bereits ausgeführt!")
End If
///

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
 
Reply With Quote
 
Cor Ligthert
Guest
Posts: n/a
 
      13th Apr 2004
Hi MS,

It is almost the same as the solution i did give you however this signature
from your program is of course better, (Herfried, can that not direct?, you
know that direct and I have to search how.)
> New Mutex(False, "{11C92606-65D9-4df2-9AEA-B6A4DA91BCE2}")


However I think that this will give you on a lot of places in the world very
much respect
> MessageBox.Show("Anwendung wird bereits ausgeführt!")


:-))

Cor


 
Reply With Quote
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      13th Apr 2004
* "Cor Ligthert" <(E-Mail Removed)> scripsit:
> It is almost the same as the solution i did give you however this signature
> from your program is of course better, (Herfried, can that not direct?, you
> know that direct and I have to search how.)
>> New Mutex(False, "{11C92606-65D9-4df2-9AEA-B6A4DA91BCE2}")


The difference is that it uses 'WaitOne' to avoid possible problems
which can occur on some machines (don't know why).

> However I think that this will give you on a lot of places in the world very
> much respect
>> MessageBox.Show("Anwendung wird bereits ausgeführt!")


Oh, sorry...

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
programmatically checking if app is running Mike P Microsoft C# .NET 2 22nd Mar 2007 05:49 PM
checking for a running app L3Tech Microsoft Excel Programming 1 19th Jan 2006 01:01 AM
Checking for other running CF applications Andrew Mac Microsoft Dot NET Compact Framework 6 22nd Sep 2004 05:18 PM
Vba - Checking if running ajliaks Microsoft Excel Programming 2 11th Sep 2004 06:09 PM
checking if app is running already? =?Utf-8?B?RGVhc3Vu?= Microsoft Dot NET 3 18th May 2004 03:18 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:50 AM.