"Named Event"

  • Thread starter Thread starter alexia.bee
  • Start date Start date
A

alexia.bee

Hi all,

I need to write app in C# that communicates with other app. I need to
use "named event" for that.
I should use windows APIs SetEvent() and WaitForSingleObject() etc...
I looked for help but couldn't find any.

Can any one please help me with that?

Thanks.
 
Aneesh,

As of .NET 2.0, you don't need to use interop to get the handle to named
events. You can call the static OpenExisting method to get a reference to
an event which already exists and is named.
 
Aneesh,

As of .NET 2.0, you don't need to use interop to get the handle to named
events. You can call the static OpenExisting method to get a reference to
an event which already exists and is named.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)





- Show quoted text -

Hello Nicholas,

thanks you and the other guys for your reply.

Can I use OpenExisting to sync with events set by app run from kernel
developed by C++?
Also, Is there a .NET way which replaces WIN API DeviceIoControl?

thanks.
 
Yes, you can use OpenExisting to get a reference to an event that was
created in a C++ program, for example, as long as they used the same
underlying API (CreateEvent, CreateEventEx, which the managed wrappers use)
with the same name.

As for DeviceIOControl, there is not a managed representation. You will
have to call the function through the P/Invoke layer.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Aneesh,

As of .NET 2.0, you don't need to use interop to get the handle to
named
events. You can call the static OpenExisting method to get a reference
to
an event which already exists and is named.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)




On Jun 3, 11:53 am, (e-mail address removed) wrote:
Hi all,
I need to write app in C# that communicates with other app. I need to
use "named event" for that.
I should use windows APIs SetEvent() and WaitForSingleObject() etc...
I looked for help but couldn't find any.
Can any one please help me with that?

- Show quoted text -

Hello Nicholas,

thanks you and the other guys for your reply.

Can I use OpenExisting to sync with events set by app run from kernel
developed by C++?
Also, Is there a .NET way which replaces WIN API DeviceIoControl?

thanks.
 
Aneesh,

As of .NET 2.0, you don't need to use interop to get the handle to
named
events. You can call the static OpenExisting method to get a reference
to
an event which already exists and is named.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)




On Jun 3, 11:53 am, (e-mail address removed) wrote:
Hi all,
I need to write app in C# that communicates with other app. I need to
use "named event" for that.
I should use windows APIs SetEvent() and WaitForSingleObject() etc...
I looked for help but couldn't find any.
Can any one please help me with that?

- Show quoted text -

Hello Nicholas,

thanks you and the other guys for your reply.

Can I use OpenExisting to sync with events set by app run from kernel
developed by C++?
Also, Is there a .NET way which replaces WIN API DeviceIoControl?

thanks.


Yes, you have to call OpenExisting to get access to the handle, of course
you will need appropriate access rights for this to scucceed.
DeviceIOControl is not covered by the FCL, so you will have to "PInvoke" the
API, following is the DllImport declaration for DeviceIoControl.


[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
internal static extern int DeviceIoControl(SafeFileHandle handle, uint
dwIoControlCode, IntPtr lpInBuffer,
int nInBufferSize, IntPtr lpOutBuffer, int nOutBufferSize,
out int lpBytesReturned, IntPtr lpOverlapped);


Willy.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top