从c#创建Win32事件 [英] Creating Win32 events from c#

查看:116
本文介绍了从c#创建Win32事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要从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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆