运行 linux 上的信号量#

Run semaphore on linux c#

我是 linux 上的 运行 信号量并且正在生成以下错误:

"Exception": {"ClassName": "System.PlatformNotSupportedException", "Message": "The named version of this synchronization primitive is not supported on this platform.", "Data": null, "InnerException": null, "HelpURL ": null," StackTraceString ":" at System.Threading.Semaphore.CreateSemaphoreCore (Int32 initialCount, Int32 maximumCount, String name, Boolean & createdNew) \ n at System.Threading.Semaphore..ctor (Int32 initialCount, Int32 maximumCount, String name, Boolean & createdNew) \ n at System.Threading.Semaphore..ctor (Int32 initialCount, Int32 maximumCount, String name) \ n "," RemoteStackTraceString ": null," RemoteStackIndex ": 0," ExceptionMethod ": null," HResult ": - 2146233031," Source ":" System.Private.CoreLib "," WatsonBuckets ": null},

有人可以帮助我吗?

Linux 不支持命名同步原语,因此 .NET Core 也不支持。

https://github.com/dotnet/runtime/issues/5211

更新 基于评论

从 .NET 5 开始,命名信号量仍不受支持。我还没有测试过其他原语。