Re: "Named Event"



<alexia.bee@xxxxxxxxx> wrote in message news:1180891516.819347.214450@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On Jun 3, 4:28 pm, "Nicholas Paldino [.NET/C# MVP]"
<m...@xxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
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]
- m...@xxxxxxxxxxxxxxxxxxxxxxxxxxx

"Aneesh P" <anees...@xxxxxxxxx> wrote in message

news:1180859377.068957.95650@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx



> On Jun 3, 11:53 am, alexia....@xxxxxxxxx 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?

>> Thanks.
> See this link:
>http://www.codeproject.com/csharp/InteropEvents.asp- Hide quoted text -

- 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.

.