如何在 C# 中创建命名的 autoresetevent?
我需要使用命名事件来同步两个应用程序。但 AutoResetEvent 和 ManualResetEvent 都不包含具有事件名称的构造函数(仅初始状态)。我可以通过 AutoResetEvent 或 ManualResetEvent 类中的静态方法 OpenExisting 打开现有的命名事件,但无法创建它!我不想使用本机 WinAPI CreateEvent 函数,除非我确切地知道不存在其他方法。
I need to synchronize two applications by using a named event. But neither AutoResetEvent nor ManualResetEvent contains constructor with a name for event (only initial state). I can open existing named event through static method OpenExisting in AutoResetEvent or ManualResetEvent class, but can't create It! I don't want to use native WinAPI CreateEvent function for It, unless I know precisely of not existing of other ways.
我自己找到了解决方案。那是:
I found a solution by myself. That is: