1

I want to create an application that close every other instance of this application at startup. for windows, I do this:

            var pr = System.Diagnostics.Process.GetProcessesByName(
                System.IO.Path.GetFileNameWithoutExtension(typeof(Program).Assembly.Location));
            var Id = System.Diagnostics.Process.GetCurrentProcess().Id;
            foreach (var p in pr.Where(x => x.Id != Id))
            {
                p.Kill(); 
            }

How can I do that with mono for OSX?

Nyashes
  • 652
  • 4
  • 22
  • Not sure 'on mono' but try a shared mutex http://stackoverflow.com/questions/819773/run-single-instance-of-an-application-using-mutex – kenny Oct 31 '13 at 13:20
  • Be aware there is a prerequisite to using shared mutexes on Mono on Linux... Not sure if the same applies on OSX, but assume it does: http://www.martyndavis.com/?p=440 – TheNextman Oct 31 '13 at 16:31
  • On windows this doesn't work well, you really want to be using a named Mutex. But there is not an equivalent on OSX or Linux because a named Mutex is a windows feature. A more complete answer is here: http://stackoverflow.com/questions/21266949/mono-alternative-for-named-mutex – Joel Barsotti Dec 03 '15 at 19:06

0 Answers0