WaitHandle::get_Handle --> HANDLE

M

Mike DeKoker

Is it safe to assume that the IntPtr returned by
System::Threading::WaitHandle::get_Handle can be cast to a HANDLE? I have a
legacy function that takes an Win32 event handle that I'm trying to wrap.

Thanks,

Mike DeKoker
 
D

Doug Harrison [MVP]

Mike said:
Is it safe to assume that the IntPtr returned by
System::Threading::WaitHandle::get_Handle can be cast to a HANDLE? I have a
legacy function that takes an Win32 event handle that I'm trying to wrap.

Yes. Just make sure the WaitHandle doesn't close its HANDLE while you're
still using it. In particular, it's undefined to close a HANDLE that you're
waiting on in a function like WaitForSingleObject. Also, the unmanaged code
shouldn't close the HANDLE as long as the WaitHandle owns it.
 

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

Top