Hello,
I have been working on a multi-threaded MFC application that needs to send information via the serial port. Everything seems to work fine apart from the fact that I need to send the information every 100ms. I have been trying to send the information based on the tick counts to know when exactly to send the information as given below but no luck so far. Any suggestions on where I am going wrong? Any help would be really appreciated.
Code:
Thread(...)
{
CDlg* appPtr = (CDlg*)lpVoid;
while(true)
{
if(appPtr->m_StartSending == true)
{
dInitialCount = GetTickCount();
if(dPRCount == 0)
dPRCount = GetTickCount();
dCurrentCount = GetTickCount();
Difference = (dCurrentCount - dPRCount);
if(Difference >= 100)
{
appPtr->SendPR(i);
dPRCount = 0;
dCurrentCount = 0;
}
}
}
SendPR(i)
{
Write(...);
Sleep(1);
}