Tag Archives: Mutex

How to allow only one application instance

The following code will ensure that your application can only have one instance active. If the user tries to open the application again while the application is already running then the application will simply quit (in this case after showing a message).

For this to work we will need to modify the Program.cs to check with the use of Mutex if the application is already running or not before we open the main form. Our check will take place in the Main method.

Your code in Program.cs should look like this:

Feel free to modify the example to suit your needs.