Using Win32 Synchronization Objects

  • Thread starter Thread starter William Stacey
  • Start date Start date
W

William Stacey

private readonly IntPtr hEvent;

hEvent = Win32Native.CreateEvent(null, true, false, null); //Or use
"name_of_event" in fourth parm.
if ( hEvent == IntPtr.Zero )
throw new ApplicationException("Error creating Event object.");

....
[DllImport("kernel32.dll")]
public static extern IntPtr CreateEvent(
SECURITY_ATTRIBUTES eventAttributes, //[in] Pointer to a
SECURITY_ATTRIBUTES structure.
bool manualReset, //[in]
bool initialState, //[in] Initial State.
string name //[in] File name. Pointer to null-terminated
string.
);
 
Hi,
I there a way in which I can obtain a handle to a Named Win32 Thread
Synchronization object (lik an Event Object or CEvent object when using
MFC ) in .Net.

Any help would be highly appreciated.

Thank You,
Sameer
 
Hi Sameer,

Based on my research, I think there are no analogous named events in .Net
framework of current version. This may be supported in the future.

For now, I think you may try to use the Win32 API call CreateEvent,
OpenEvent and so on to achieve your aim. For the Mutex class, you can use
the named object, you may take a look at the contructor of Mutex.

If you have any concern on this issue, please post here.

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Back
Top