Created
February 17, 2016 15:08
-
-
Save kristopherjohnson/f94a52073e77fc9c46f9 to your computer and use it in GitHub Desktop.
Example of using a Mutex to determine if .NET application is already running
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| bool mutexIsNew; | |
| using (System.Threading.Mutex m = | |
| new System.Threading.Mutex(true, uniqueName, out mutexIsNew)) | |
| { | |
| if (mutexIsNew) | |
| // This is the first instance. Run the application. | |
| else | |
| // There is already an instance running. Exit! | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment