Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating Win32 events from c#

Tags:

c#

events

interop

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?

like image 212
ofer Avatar asked Jan 15 '09 16:01

ofer


People also ask

What is a Win32 event?

The win32-event library provides an interface to Windows event objects. An event object is a synchronization object whose state can be explicitly set to a signaled state. Event objects are useful in sending a signal to a thread indicating that a particular event has occurred.

Is Win32 API still used?

Over the years, Microsoft has adopted it internally for the development of Office 365, Skype, and other applications. That was 16 years ago. However, Win32 still is the predominant legacy programming API. More apps out in the wild use it than anything else.

Is Win32 a C++?

Win32++ is a C++ library used to build windows applications. Win32++ is a free alternative to MFC. It has the added advantage of being able to run on a wide range of free compilers, including Visual Studio Community, Clang, and the MinGW compiler provided with CodeBlocks and Dev-C++.

What is Createeventw?

The CreateEvent function creates a named or unnamed event object.


1 Answers

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.

like image 141
Stu Mackellar Avatar answered Oct 12 '22 13:10

Stu Mackellar