为中的命名全局互斥体指定MutexSecurity.NET核心



是否有方法将MutexSecurity传递给中的Mutex。NET Core(目前仍在使用2.2,将来将切换到.NET 6(?

NET Framework有一个接受此参数的构造函数,但它似乎已在中删除。NET核心。

In。NET 6.0中有MutexAcl类:

#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

可通过系统获得。线程。AccessControl nuget包。

如果不在Windows上,该方法将抛出PlatformNotSupportedException(自然(。

最新更新