[Mono-list] Problem enumerating all mono processes on the system.

Chris Howie cdhowie at gmail.com
Sun Aug 17 02:55:34 EDT 2008

On Sun, Aug 17, 2008 at 1:18 AM, Brett Senior <brett_senior at yahoo.com.au> wrote:
> The following is some code that I have written to determine if the currently
> running program is already running.  The way that I tackled it was to search
> for all mono processes and then within the process module collection to see
> if any of them match the name of the program (minus the directory part of
> the filename) then I increment a counter.  If the counter is greater than
> one then the program returns true, otherwise false.
> Problem is that even if I have multiple instances of program 'xxx' running
> using mono, only one mono process is returned.  Within this process then
> only one instance of 'xxx' is found in the process module collection.  So
> the below is unable to detect multiple instances of the program.
> Can someone look at the below and point out what I am doing wrong ?

Have a look at the System.Threading.Mutex class, in particular named
mutexes.  You can use this to create a system-wide handle that you can
examine from another process to see if it's in use.

Chris Howie

More information about the Mono-list mailing list