https://msdn.microsoft.com/en-us/library/windows/desktop/aa363424(v=vs.85).aspx - monitring events. https://msdn.microsoft.com/en-us/library/windows/desktop/aa363479(v=vs.85).aspx https://msdn.microsoft.com/en-us/library/windows/desktop/ms687069(v=vs.85).aspx Wait Functions The following example code opens the serial port for overlapped I/O, creates an event mask to monitor CTS and DSR signals, and then waits for an event to occur. The WaitCommEvent function should be executed as an overlapped operation so the other threads of the process can perform I/O operations during the wait. process.h /* * The functions _beginthreadex and _endthreadex are not provided by CRTDLL. * They are provided by MSVCRT. * * NOTE: Apparently _endthread calls CloseHandle on the handle of the thread, * making for race conditions if you are not careful. Basically you have to * make sure that no-one is going to do *anything* with the thread handle * after the thread calls _endthread or returns from the thread function. * * NOTE: No old names for these functions. Use the underscore. */ unsigned long _beginthread (void (*)(void *), unsigned, void*); void _endthread (void); #ifdef __MSVCRT__ unsigned long _beginthreadex (void *, unsigned, unsigned (__stdcall *) (void *), void*, unsigned, unsigned*); void _endthreadex (unsigned); #endif