简体   繁体   English

进程间上下文中的.net EventWaitHandle

[英].net EventWaitHandle in Inter-Process Context

when creating a named EventWaitHandle in each process you can specifiy in which state it should be. 在每个进程中创建一个命名的EventWaitHandle时,您可以指定它应该处于哪个状态。 Now this somehow contradicts the assumption that the EventWaitHandle is usable for IPC as another process might have set the state to "signalled" whereas I (when creating the EventWaitHandle) can set it to "not signalled". 现在,这在某种程度上与以下假设相矛盾:EventWaitHandle可用于IPC,因为另一个进程可能已将状态设置为“已发出信号”,而我(在创建EventWaitHandle时)可以将其设置为“未发出信号”。

Any ideas? 有任何想法吗?

thanks, Chris 谢谢克里斯

Did you read the documentation ? 你看过文件了吗?

From the page: 从页面:

When using this constructor for named system events, specify false for initialState. 当将此构造函数用于命名系统事件时,请为initialState指定false。 This constructor provides no way to determine whether a named system event was created, so you cannot make any assumptions about the state of the named event. 此构造函数无法确定是否创建了命名系统事件,因此您无法对命名事件的状态进行任何假设。 To determine whether a named event was created, use the EventWaitHandle(Boolean, EventResetMode, String, Boolean) constructor or the EventWaitHandle(Boolean, EventResetMode, String, Boolean, EventWaitHandleSecurity) constructor. 要确定是否创建了命名事件,请使用EventWaitHandle(Boolean,EventResetMode,String,Boolean)构造函数或EventWaitHandle(Boolean,EventResetMode,String,Boolean,EventWaitHandleSecurity)构造函数。

If that is the constructor you're using, then the documentation for thaf constructor indicates that the initialState flag is only used when your call creates the event. 如果这是您正在使用的构造函数,则thaf构造函数的文档指示仅在调用创建事件时才使用initialState标志。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM