貌似 挂起线程 必须在主界面的UI线程去操作
UINT UiThreadProcessProtocol(LPVOID lParam)
{
CCalcPPIView* view = (CCalcPPIView*)lParam;
DmcControler* Dmc = &(view->Dmc);
while (1)
{
//AfxTrace("%u \n",GetTickCount());
Sleep(500);
}
return 0;
}
CWinThread* m_ThreadProcessProtocol;
m_ThreadProcessProtocol = AfxBeginThread(UiThreadProcessProtocol,this);
void CCalcPPIView::OnBtnRegulate()
{
if (m_ThreadProcessProtocol!=NULL) {
m_ThreadProcessProtocol->SuspendThread();
AfxTrace("SuspendThread() at %u \n",GetTickCount());
}
{
CRegulate dlg(this);
dlg.DoModal();
}
if (m_ThreadProcessProtocol!=NULL) {
m_ThreadProcessProtocol->ResumeThread();
AfxTrace("ResumeThread() at %u \n",GetTickCount());
}
}
void CCalcPPIView::CloseDevice(BOOL bUpdateUI )
{
CCalcPPIView* view = this;
AfxTrace("CCalcPPIView::CloseDevice() Entry \n");
Dmc.SetOpened(0);
if (view->m_ThreadProcessProtocol!=NULL) {
WaitForSingleObject(view->m_ThreadProcessProtocol->m_hThread,INFINITE);
view->m_ThreadProcessPro NULL;
}
}