Friday, May 28, 2010

Asynchronous I/O

bool fQuit = false;
while (!fQuit)
{
// Wait for a communication event or windows message

switch (::MsgWaitForMultipleObjects(1,&hevtCommEvent,FALSE,INFINITE,QS_ALLEVENTS))
{
case WAIT_OBJECT_0:
{
// There is a serial communication event, handle it...

HandleSerialEvent();
}
break;

case WAIT_OBJECT_0+1:
{
// There is a windows message, handle it...

MSG msg;
while (::PeekMessage(&msg,0,0,0,PM_REMOVE))
{
// Abort on a WM_QUIT message

if (msg.message == WM_QUIT) { fQuit = true; break; }

// Translate and dispatch the message

::TranslateMessage(&msg);
::DispatchMessage(&msg);
}
}
break;

default:
{
// Error handling...

}
break;
}
}

No comments:

Post a Comment

do u hav any doubts just mail us.our team will find the solution for it and we will clarify it as soon.



regards;
S-TECHNOLOGIES team