Is there a way to pass MutexSecurity
to a Mutex
in .NET Core (currently still using 2.2, switching to .NET 6 in the future)?
.NET Framework has a constructor accepting this parameter, but it seems to have been removed in .NET Core.
In .NET 6.0 there is the MutexAcl
class:
#if NET6_0_OR_LATER
using (var mutex = MutexAcl.Create(false, mutexId, out bool createdNew, securitySettings))
#else
using (var mutex = new Mutex(false, mutexId, out bool createdNew, securitySettings))
#endif
Which is available through the System.Threading.AccessControl nuget package.
The method will throw PlatformNotSupportedException
if not on Windows (naturally).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With