Hi David: This is an easier approach, but it does have three weaknesses that might cause problems, depending on the requirements.
1) Race conditions. Imagine two instances starting at nearly the same time, seeing each other, and both shutting down. 2) I don't believe GetProcessByName will retrieve processes in other sessions under terminal services. 3) It doesn't account for someone else writing a process with the same name. -- Scott http://www.OdeToCode.com/blogs/scott/ -----Original Message----- From: Unmoderated discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED] On Behalf Of David Lanouette Sent: Tuesday, March 01, 2005 1:25 PM To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM Subject: Re: [ADVANCED-DOTNET] System global Mutex You could also just look to see if the process is already running. I would think this would be lighter weight (don't need to keep a mutex around all the time) ex. Process currProcess = Process.GetCurrentProcess(); Process [] runningProcesses = Process.GetProcessesByName(currProcess.ProcessName); if (runningProcess.Length > 1) { //Its already running return; } =================================== This list is hosted by DevelopMentorR http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com =================================== This list is hosted by DevelopMentorŪ http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com