Problem with thread
-
Hi dear, I created a thread. But when I start the thread CPU load become 100%. I use these code.
void CtestDlg::BeginThread() { m_isRunning = TRUE; AfxBeginThread(ThreadStart,this,THREAD_PRIORITY_LOWEST); } UINT CtestDlg::ThreadStart(LPVOID pParam) { CtestDlg* pDlg = (CtestDlg*)pParam; if (pDlg == NULL || !pDlg->IsKindOf(RUNTIME_CLASS(CtestDlg))) return 1; // if pEventLine is not valid while(pDlg->m_isRunning) pDlg->Start(); return 0; // thread completed successfully } void CtestDlg::Start() { }
Start function doesn't have any code. Thank you in advance. -
Hi dear, I created a thread. But when I start the thread CPU load become 100%. I use these code.
void CtestDlg::BeginThread() { m_isRunning = TRUE; AfxBeginThread(ThreadStart,this,THREAD_PRIORITY_LOWEST); } UINT CtestDlg::ThreadStart(LPVOID pParam) { CtestDlg* pDlg = (CtestDlg*)pParam; if (pDlg == NULL || !pDlg->IsKindOf(RUNTIME_CLASS(CtestDlg))) return 1; // if pEventLine is not valid while(pDlg->m_isRunning) pDlg->Start(); return 0; // thread completed successfully } void CtestDlg::Start() { }
Start function doesn't have any code. Thank you in advance.your while loop will generate 100% cpu, since you dont have any kind of blocking code inte CtestDlg::Start. What the CPU is doing is calling Start all the time. Magnus