Helper Apps and Mutex

Got the example from Valdemar de Sousa described here working: https://forum.xojo.com/12479-helper-apps-and-the-sandbox . But how do I handle mutexes? I was able to start both helper app and main app multiple times. This would totally mess up my application.

It is not Valdemar’s code : I verified with another app of mine. For some reason, the usual Mac OS X behavior does not work. Sandboxed or not.

I followed exactly the example at http://documentation.xojo.com/index.php/Mutex and it works perfectly.

@Michel: can the mutex differentiate between the 2 different apps? With Valdemars’s code the main app and the helper app now have both the same bundle ids.

Sure. Each app has its own mutex. Just have a unique value in this line :

mMutex = New Mutex("MutexExample")

You can set your Mutex to anything that will be unique to the app, for instance “valdemarshelperapp” and “mygreatandbeautifulapp”. Mutex works by that name, not by the bundle id.

@Michael: ah, light bulb goes on. Thanks!