I have an application wherein I am sharing event handles across threads. These event handles are used to signal transmit complete and received data notifications of serial I/O to the application. The handles are copied to the new threads as a passed parameter of class constructors or calls to CreatThread
. I thought this was working, but I've run into a weird bug where it seems like these events may not be getting properly signaled. Should I be using the DuplicateHandle
function for this? If so, would the following usage be correct?
::DuplicateHandle(
::GetCurrentProcessId(),
hMyHandle,
::GetProcessIdOfThread( hReceivingThreadHandle ),
&hMyDupHandle,
0,
TRUE,
DUPLICATE_SAME_ACCESS
);
Unfortunately, I cannot be 100% certain about this bug because multi-thread debugging is tricky. Thanks.