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);
}
Jim
ATP BE400 CE500 (C550B-SPW) CE560XL MU300 CFI CFII
"The speed of non working code is irrelevant"... Of course that is just my opinion, I could be wrong.
"Nothing in the world can take the place of persistence. Talent will not; nothing is more common than unsuccessful men with talent. Genius will not; unrewarded genius is almost a proverb. Education will not; the world is full of educated derelicts. Persistence and determination are omnipotent. The slogan 'press on' has solved and always will solve the problems of the human race."...Calvin Coolidge 30th President of the USA.
Bookmarks