"nickdu" <nicknospamdu[ at ]community.nospam> wrote in message
news:B6238BF5-DA74-41BA-B588-699CE21DD702[ at ]microsoft.com...
> I'm using interop (PInvoke) to call a method
> (FindFirstPrinterChangeNotification) which returns an event handle. I
> like to stay as much as possible in managed code so I want to get this
> event handle into a managed WaitHandle so I can call one of the
> Wait() methods. How do I do this?
> The only way I see is to either:
> 1. Create an EventWaitHandle instance and then set the SafeWaitHandle
> property. The problem with this route is that it will first create an
> object that I don't need.
> 2. Derive a class from WaitHandle so that I can get access to its
> constructor which accepts a SafeWaitHandle.
I'd personally go with option 2, not necessarily just to get access to a
protected constructor, but because the WaitHandle class is designed to wrap
a native OS handle.
Seems like a simple, clean solution to me.
Microsoft MVP - Visual C++
> Is there some other way? I was hoping there was an exposed way to create
> WaitHandle from a native event handle.
> nicknospamdu[ at ]community.nospam
> remove "nospam" change community. to msn.com