Home
Manage Your Code
Snippet: C#: How to allow only one instance of an application to run. (C#)
Title: C#: How to allow only one instance of an application to run. Language: C#
Description: Add this method in the Program.cs and call this function within the main() function. Views: 923
Author: Esteban Ochoa Date Added: 6/29/2007
Copy Code  
1 private static void onlyOneAppInstance()
2        {
3            Mutex appSingleton = new System.Threading.Mutex(false, "SingleInstanceRegistroActivo");
4            if(appSingleton.WaitOne(0, false))
5                Application.Run(new Login());
6            appSingleton.Close();
7        }