worker thread, serial communication, UI freeze

worker thread, serial communication, UI freeze

Post by TWljaGF » Fri, 30 Apr 2004 07:26:03


I have utility that works on iPaq PPC2000 and PPC2002. I need to rewrite it for Windows Mobile 2003. After I recompile project (Win 2K, EVC++4, HP iPaq 2200, not MFC, platform PPC2003) utility freeze after it creates worker thread, that receive bytes from uart
I get error message from de *** : DM0024: All threads are suspended. What exactly means this message

DWORD PortReadThread(LPVOID lpvoid

BYTE Byte
DWORD dwCommModemStatus
dwBytesTransferred


// Specify a set of events to be monitored for the port
SetCommMask (hPort, EV_RXCHAR | EV_CTS | EV_DSR | EV_RLSD | EV_RING)

while (hPort != INVALID_HANDLE_VALUE)

// Wait for an event to occur for the port
WaitCommEvent (hPort, &dwCommModemStatus, 0); // FREEZ

// Re-specify the set of events to be monitored for the port
SetCommMask (hPort, EV_RXCHAR | EV_CTS | EV_DSR | EV_RING)

if (dwCommModemStatus & EV_RXCHAR)

// Loop for waiting for the data
do

// Read the data from the serial port
ReadFile (hPort, &Byte, 1, &dwBytesTransferred, 0)

if (dwBytesTransferred == 1)
ProcessChar(Byte)

} while (dwBytesTransferred == 1)


return 0


//---------
// Create a read thread for reading data from the communication port
if (hReadThread = CreateThread (NULL, 0, PortReadThread, 0, 0, &dwThreadID)

CloseHandle (hReadThread)

//----------