Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/321.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 不支持.NET Core 2.1 EventWaitHandle吗?_C#_.net Core - Fatal编程技术网

C# 不支持.NET Core 2.1 EventWaitHandle吗?

C# 不支持.NET Core 2.1 EventWaitHandle吗?,c#,.net-core,C#,.net Core,我正在将一个C#.NET框架项目转换为.NET核心。它编译时没有错误或警告,在Windows上运行良好,但当我在CentOS 7上尝试时,当我尝试创建EventWaitHandle实例时,会得到System.PlatformNotSupportedException。代码如下: this.eventHandle = new EventWaitHandle(initialState, resetMode, name); 显然,该类支持.NET Core 2.1,因为此处有MS文档: 这是否像错

我正在将一个C#.NET框架项目转换为.NET核心。它编译时没有错误或警告,在Windows上运行良好,但当我在CentOS 7上尝试时,当我尝试创建EventWaitHandle实例时,会得到System.PlatformNotSupportedException。代码如下:

this.eventHandle = new EventWaitHandle(initialState, resetMode, name);
显然,该类支持.NET Core 2.1,因为此处有MS文档:

这是否像错误描述的那样简单,并且跨多个平台不支持该类?如果是,为什么它包含在.NET核心中?这里还有什么别的事吗

如果它只是不受支持,是否有人可以推荐一个在.NETCore2.1中完全受支持的替代类


谢谢。

.netcore有一些特定于平台的API。这是其中之一。它是无法处理的命名句柄,请参见

公共EventWaitHandle(bool initialState、EventResetMode模式、字符串名称) { if(name!=null) { #如果平台是UNIX 抛出新的PlatformNotSupportedException(Environment.GetResourceString(“PlatformNotSupported_NamedSynchronizationPrimitives”); #否则 if(System.IO.Path.MaxPath 更有趣的是:

我不确定您应该使用什么.NET技术。如果不需要跨进程同步,则不需要为EventWaitHandle指定名称,也可以使用EventWaitHandle的其他子类,如ManualResetEvent或AutoResetEvent


您是否正在使用任何NuGet软件包?添加更多信息…我正在使用此软件包进行跨进程同步。@Moffen,我目前没有使用任何NuGet软件包。显而易见的方法可能是编写一个拉取请求,这样,.NET Core 2.2将获得支持…显然,并非完全不重要。具体取决于您的场景(也就是说,没有太多的事件,没有太多的调用),你可以通过轮询文件来实现一些穷人的同步机制。嘿@mojoker,你有没有找到解决方案?看起来好像还没有解决。
    public EventWaitHandle(bool initialState, EventResetMode mode, string name)
    {
        if(name != null)
        {
#if PLATFORM_UNIX
            throw new PlatformNotSupportedException(Environment.GetResourceString("PlatformNotSupported_NamedSynchronizationPrimitives"));
#else
            if (System.IO.Path.MaxPath < name.Length)
            {
                throw new ArgumentException(Environment.GetResourceString("Argument_WaitHandleNameTooLong", name));
            }
#endif
        }

        ...