Skip to content

Instantly share code, notes, and snippets.

@kristopherjohnson
Created February 17, 2016 15:08
Show Gist options
  • Select an option

  • Save kristopherjohnson/f94a52073e77fc9c46f9 to your computer and use it in GitHub Desktop.

Select an option

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
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