Only one app running in MAC?

Dani_S 3,296 Reputation points


Does this code work on MAC, only one app running ?


public partial class App : Application


 private static Mutex mutex = new Mutex(true, Assembly.GetEntryAssembly().GetName().Name);

 public App()


     if (!mutex.WaitOne(TimeSpan.Zero, true))




A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,184 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce ( 60,871 Reputation points

    not on any O/S. The .net Mutex instance is tried to the process, its basically a static variable.

    if a name string is passed, a system mutex is used and works.

    On windows you would use the NT named mutex. On MacOS you would use the named pthread mutexes. if you pass a string, .net uses O/S mutex.

    On MacOs the Desktop already defaults to one instance, but you can start a second via terminal. But rather than a named mutex it is better to use NSWorkspace which has a list of running applications.