Ensure only one instance running
Graeme Hood <[email protected]> Fri, 21 Dec 2007 14:53:16 +0100
| Newsgroups | gmane.comp.windows.devel.dotnet.winforms |
|---|---|
| Message-ID | <[email protected]> |
I have this code to make sure my app can't run twice. But I seem to remember there was a newer/better way in the latest .Net FW. Is there? ==================================================== public static void Main() bool firstInstance = false; string safeName = Application.UserAppDataPath.Replace(@"\", "_"); Mutex mutex = new Mutex(true, safeName, out firstInstance); if (!firstInstance) return; This email message is intended only for the use of the named recipient. Information contained in this email message and its attachments may be privileged, confidential and protected from disclosure. If you are not the intended recipient, please do not read, copy, use or disclose this communication to others. Also please notify the sender by replying to this message and then delete it from your system.