I always thought that if 2 versions of the same app that have identical bundle identifiers can only be started once. But I have an invisible helper app that I can start several times. During testing I’ve seen this now and then. However, since the helper app is supposed to start the main app when a certain time has passed this leads to confusion when the main app is started 2 times.
Before I investigate deeper why the app is started multiple times: how can I prohibit this better on system level? I vaguely know about mutexes on the Windows side but I always thought that the Mac handles this automatically.
Mac OS 10.8.4.
You can use mutex on the Mac too, exactly how it’s used on Windows.
Just declare a mutex like this on the App.Open event of your application (and keep a reference to it as an app property:
appMutex = new Mutex("com.mycompany.myapp") //using the Bundle Identifier
// try to get a lock on mutex
if not appMutex.TryEnter then
// immediately quit if a lock can't be obtained
then in the App.Close event release the mutex:
// free the lock on mutex
if appMutex <> nil then
On why this happen on Mac:
If you launch an application from Finder, then you can’t launch two copies, but that’s not true if you launch the application from the command line (and helpers are normally in this category).
Thanks! Will try the mutex.
But I was able to start the helper app 2 times from Finder. Anyhow, the mutex should be enough.
You can use the terminal command “open -n” to force the OS to open a new instance of your OS X app. Presumably, if you leave the “-n” off it should not do that.