My program has 2 thread. The main thread controls the GUI and the second thread listens for event created by the COM port. I use WaitCommEvent to wait for a EV_RXCHAR in Non Overlapped Mode.
How can I stop this thread while it is waiting for the event ??????
Posted on 2002-10-12 15:06:00 by greenant
you need to use the OVERLAPPED structure for WaitCommEvent. With it, the function
returns immediatly and you can ask the hEvent for complete-ness of comm operation.

Now create a second event for signaling "stop" action. Wait inside the IO-thread with
WaitForMultipleObjects for two events - one from the overlap struc and the stop-event.

Now you can signal the stop event from GUI thread, so the IO-thread can terminate
(ExitThread) itself. If the overlap event becomes signaled, continue like you need to.
Posted on 2002-10-15 11:53:56 by beaster