Is there any way to share a mutex between a UWP app and a desktop bridge app in the same package? They seem to have different namespaces; using the same name doesn't yield the same object between the processes. The UWP app's objects are, according to WinObj
, stored in a special namespace under AppContainerNamedObjects\{APP_SID}
rather than under BaseNamedObjects
like usual. However, the desktop app - despite running from the same app bundle - does use the BaseNamedObjects
namespace, and consequently the two processes can't share synchronization objects.
Is there any way around this? The best I've thought of involves silly things like checking for files to exist or not, but this is both overly complicated and underperformant. Mutexes are simple, fast, and designed for exactly this use case (synchronization across processes); can they just not be used here?
winobj
from Sysinternals, you can find the path that is used for AppContainerNamedObjects. It's in a subdirectory ofBaseNamedObjects
, IIRC (I'm not at a Windows box right now). You can (even though MSDN says you can't) access or create that path by putting` characters in your object name, just like you would for a file. The object path will be treated as relative to
BaseNamedObjects`. Watch for weird behavior, like the UWP app might not be able to open the object if it is created by the desktop app, and the path won't exist if the UWP isn't running. – Telophase