I'm creating a thread like this:
m_pCListenThreadList[0] = new CListenThread();
m_pCListenThreadList[0]->CreateThread(CREATE_SUSPENDED, 0);
m_pCListenThreadList[0]->SetParent(this, &m_SerialListenControl, &m_SerialListen, "COM1");
m_pCListenThreadList[0]->ResumeThread();
Within this thread I'm using WaitCommEvent(m_tComm, &dwEvtMask, &overlapped); to listen to the serial port.
This is how I end the thread:
m_pCListenThreadList[0]->SuspendThread();
m_pCListenThreadList[0]->End();
CloseHandle(m_pCListenThreadList[0]);
::TerminateThread(m_pCListenThreadList[0],1);
delete m_pCListenThreadList[0] ;
But the thread wont terminate unless something is coming to the serial port. It waits at WaitCommEvent. If something comes it terminates but I want to kill it even if nothing has come.
How do you do this?
/Andreas