"nickdu" <nicknospamdu[ at ]community.nospam> wrote in message news:B6238BF5-DA74-41BA-B588-699CE21DD702[ at ]microsoft.com...
[Quoted Text] > I'm using interop (PInvoke) to call a method > (FindFirstPrinterChangeNotification) which returns an event handle. I > would > like to stay as much as possible in managed code so I want to get this > native > event handle into a managed WaitHandle so I can call one of the > WaitHandle's > 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 > event > object that I don't need. > > 2. Derive a class from WaitHandle so that I can get access to its > protected > 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.
Mark
-- Mark Salsbery Microsoft MVP - Visual C++
> Is there some other way? I was hoping there was an exposed way to create > a > WaitHandle from a native event handle. > -- > Thanks, > Nick > > nicknospamdu[ at ]community.nospam > remove "nospam" change community. to msn.com
|