I have a single-thread application that communicate with some hardware. I need to have a delay after writing some data to the comm port before i read the data returned by the hardware.
Now i am using the sleep() command which i don't like.
I was thinking using something like :
void MySleep( int millisecond )
CTime t1 = GetCurrentTime();
PeekMessage, translate, dispatch ... etc.
CTime t2 = GetCurrentTime();
CTimeSpan sp = t2-t1;
if (sp.GetTotalSecond() > millisecond / 1000)
Is there better implementation than this? ... btw, and I cannot use the WM_TIMER.
Sample code appreciated.