DWORD WINAPI SerialThread(LPVOID lpParameter) { CSerialPort* pSeriell; pSeriell=(CSerialPort*)lpParameter; _ftime(&pSeriell->LastTime); pSeriell->LastInterruptTime=pSeriell->LastTime; while (1) { // Set actual Timer Value struct _timeb ActTime; _ftime(&ActTime); int dt=DiffTime_int(ActTime,pSeriell->LastTime); int newTime=pSeriell->m_Time; newTime+=dt; while (newTime>=TIMEMAX) newTime-=TIMEMAX; pSeriell->m_Time=newTime; pSeriell->LastTime=ActTime; // Check for Input Message if (pSeriell) { if (pSeriell->RxBufferLen==0) int Len=pSeriell->RxFrameDirect(pSeriell->RxBuffer,RxBufferSize,false); if (Len>0) { // Erfolgreicher Empfang pSeriell->RxBufferLen=Len; // Aufrufen der CallBack Funktion, wenn definiert if (pSeriell->m_pRxCallBackFunc) pSeriell->m_pRxCallBackFunc(pSeriell->m_pCallBackObject); } } } Sleep(1); } return 0; }