Proper inter-process sync (e.g. named mutex) between C++ & C# .NET 7 processes on Win & MacOS #87475
Unanswered
Volodymyr-Kashyn
asked this question in
Q&A
Replies: 1 comment
-
Since the documentation doesn't specify what underlying OS features are used for inter process mutexes, I'd recommend using PInvokes to access the native APIs from C# instead to guarantee it being the same one as the one used in your C++ code. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi!
Is there any simple cross-platform Win&MacOS way of syncing two processes: Native C++ and .NET 7 app (e.g. MAUI)?
Problem: synchronize read-write access to a file. Both processes can read & write.
For Windows it is pretty easy. Named mutex is used:
first, initialize System.Threading.Mutex with a name arg in .NET app and use CreateMutexEx in native C++ app.
However, I cannot find proper easy solution for MacOS (arm & Intel).
What I understand is that named version of System.Threading.Mutex is based on file locks in MacOS. However, I cannot find file instance for it, which contains a name of my mutex.
At least, if there's a static file based on my mutex name, probably I can use native
flock
for syncing in C++ app.Questions:
Where can I find locked file which is used for sync in MacOS?
/tmp/.dotnet
or$TMPDIR/.dotnet
does not contain anything similar to my mutex name.Are there any proper, better or even OOB ways for inter-process synchronization between C++ & .NET 7 app for MacOS?
Beta Was this translation helpful? Give feedback.
All reactions