I'm very bad in thread concept.I searched Google and got lot of examples about thread. But in my knowledge i couldn't understand B'cos the process was very heavy.
Pls give any simple examples about thread.
I'm using VC 2003 Dialog based MFC Application. I'm using serial communication using RS232(Comport 6) & RS485(Comport 4). I created a thread like below.
void CXRayFIDlg::XRayThreadRun()
{
PTSobj.ObjSensor(); //Write method using comport 6
PTSobj.ReadPortFromFrame(); //read method using comport 6
CDialog::KillTimer(1);
CDialog::KillTimer(2);
CDialog::KillTimer(3);
CDialog::KillTimer(4);
CDialog::SetTimer(5,10,NULL);
if(!XRAYThreadStop) //True only when i close my application
AfxBeginThread(XRayThread,this);
else
AppQuitFlag = true;
}
void CXRayFIDlg::OnTimer(UINT nIDEvent)
{
if(nIDEvent == 1)
{//Notify object sensor for every sec like FLT & MON
if(ERROR_CHECK == TRUE && KillTmr == FALSE)
{
InsideTimer = TRUE;
// Process ===> Read & Write process using com port 4
InsideTimer = FALSE;
}
}
if(nIDEvent == 2)
{
// Write process using com port 4
CDialog::KillTimer(2);
CDialog::SetTimer(1,1000,NULL);
}
if(nIDEvent == 3)
{
//Write process using com port 4
CDialog::KillTimer(3);
KillTmr = false;
CDialog::SetTimer(1,1000,NULL);
}
if(nIDEvent == 4)
{
//Write process using com port 4
CDialog::KillTimer(4);
CDialog::SetTimer(1,1000,NULL);
}
Bookmarks