从c#创建Win32事件 [英] Creating Win32 events from c#
问题描述
我必须互操作并打包原生的CreateEvent函数,或者已经有一个.NET类做这个工作?
我需要运行的函数应该是这样的:
hEvent = CreateEvent(NULL,false,false,MyCSHARPEvent);
这应该通知所有procs发现有关事件的MYCSHARPEvent。
如果需要包装功能,我会将SECURITY_ATTRIBUTES结构从C#翻译成win32吗?
看看 EventWaitHandle 类。它从.Net 2.0开始支持,并允许创建命名事件。它还支持根据您使用的构造函数设置事件安全性。
I'd like create a kernel(aka named events) from C#.
Do I have to interop services and wrap the native CreateEvent function or is there already a .NET class that does the job?
The function that I need to run should be something like this: hEvent = CreateEvent ( NULL , false , false , "MyCSHARPEvent" );
This should notify all procs that probing forMyCSHARPEvent about the event.
If there is a need to wrap the function, how would I translate the SECURITY_ATTRIBUTES struct from C# to win32?
Take a look at the EventWaitHandle class. It's supported from .Net 2.0 onwards and allows creation of named events. It also supports setting event security, depending on which constructor you use.
这篇关于从c#创建Win32事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!