Single of Instance Application

H

Harsh

Hello everybody I want to make sure that only a single
instance of my application is running.

i.e if the application is already running then on the
launch of application (exe) it should prompt the user
saying only one instance is allowed.

What is the best way to achieve this please using C#?


Harsh
 
H

Herfried K. Wagner [MVP]

* "Harsh said:
Hello everybody I want to make sure that only a single
instance of my application is running.

i.e if the application is already running then on the
launch of application (exe) it should prompt the user
saying only one instance is allowed.

What is the best way to achieve this please using C#?

See:

<http://www.google.com/groups?selm=eJCwBK#[email protected]>

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>

<http://www.plig.net/nnq/nquote.html>
 
H

Herfried K. Wagner [MVP]

* "Alvin Bruney said:
Process[] processes =
Process.GetProcessesByName(stProcName);if(processes.Length != 1)return
false; /*false no instance exist*/elsereturn true; /*true mean instance

This can cause problems if there are multiple processes of _different_
applications with the same name.
 

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

Top