Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //simple,fast but not 100% reliable way to check if there are more instances of the current application
- public static bool IsUniqueInstance()
- {
- string processName = Process.GetCurrentProcess().ProcessName;
- var currentProcess = Process.GetProcessesByName(processName);
- return currentProcess.Length == 1;
- }
- //this are more complex and reliable:
- //MUTEX version: http://odetocode.com/blogs/scott/archive/2004/08/20/the-misunderstood-mutex.aspx
- //MUTEX version with switch to application: http://sanity-free.org/143/csharp_dotnet_single_instance_application.html
Advertisement
Add Comment
Please, Sign In to add comment