Re: Ensure only one instance running
Phil Sayers <[email protected]> Fri, 21 Dec 2007 09:00:34 -0500
| Newsgroups | gmane.comp.windows.devel.dotnet.winforms |
|---|---|
| Message-ID | <[email protected]> |
I was incorrect... just google for this full text string "How to: Specify Instancing Behavior for an Application " -----Original Message----- From: Discussion forum for developers using Windows Forms to build apps and controls [mailto:[email protected]]On Behalf Of Graeme Hood Sent: Friday, December 21, 2007 8:53 AM To: [email protected] Subject: [DOTNET-WINFORMS] Ensure only one instance running 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.