WaitHandle::get_Handle --> HANDLE

  • Thread starter Thread starter Mike DeKoker
  • Start date Start date
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
 
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.
 
Back
Top