Check if instance of exe is running already

G

Guest

What is the C# command/function for checking to see if another instance of
the application is already running?
 
W

Willy Denoyette [MVP]

Rob said:
What is the C# command/function for checking to see if another instance of
the application is already running?


Use a mutex like this:

...
bool firstInstance;
using (Mutex AppMutex = new Mutex(true, new
Guid("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx").ToString(), out firstInstance))
{
if (firstInstance== true)
{
// run your code from here
}
} // mutex released here.
...


Willy.
 

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