Thursday, January 17, 2013

Run single instance of app in c#

accepted
To run a single instance of application in C#. Following code snippet can be usefull.

bool createdNew;

Mutex m = new Mutex(true, "myApp", out createdNew);

if (!createdNew)
{
    // myApp is already running...
    MessageBox.Show("myApp is already running!", "Multiple Instances");
    return;
}