Posted in Uncategorized

C# Single Instance Application Code

Date December 4th, 2006

This snippet will only allow a single instance of you C# application to run at any one time. All you have to do is insert it into the Main() method.

bool IsFirstInstance;
Mutex mutex = new Mutex(false,
"Local\\[name of application here]",
out IsFirstInstance);

if (IsFirstInstance)
{
Application.Run(new form_Main());
}
Application.Exit();

Leave a Reply

(required)

(required)