#2
WebKiller2015-02-04 11:19
|
只有本站会员才能查看附件,请 登录
如图为什么 线程执行到这一步,然后我点停止按钮,主线程就卡在WaitForSingleObject就没响应了
程序代码:
void CTskCoolCardDlg::OnBtnstop()
{
// TODO: Add your control notification handler code here
if(m_hThread)
{
ResumeThread(m_hThread);
InterlockedExchange((long*)&s_bStart,FALSE); //s_bStart设为false让线程退出死循环返回0
WaitForSingleObject(m_hThread,INFINITE);
CloseHandle(m_hThread);
m_hThread = NULL;
MessageBox(_T("线程关闭成功"));
}
}
{
// TODO: Add your control notification handler code here
if(m_hThread)
{
ResumeThread(m_hThread);
InterlockedExchange((long*)&s_bStart,FALSE); //s_bStart设为false让线程退出死循环返回0
WaitForSingleObject(m_hThread,INFINITE);
CloseHandle(m_hThread);
m_hThread = NULL;
MessageBox(_T("线程关闭成功"));
}
}
程序代码:
else
{
s_pCtl->SetWindowText(_T("关闭所有端口,等待1秒"));
OnClickStartOrStopBtn(hwnd,FALSE);
Sleep(1000);
s_pCtl->SetWindowText(_T("开启所有端口,等待8秒"));
OnClickStartOrStopBtn(hwnd,TRUE);
Sleep(8000);
}
}
if(10 == i)
{
AfxMessageBox("开启十连败,请手动调整机器");
return FALSE;
}
s_pCtl->SetWindowText(_T("所有端口开启成功"));
{
s_pCtl->SetWindowText(_T("关闭所有端口,等待1秒"));
OnClickStartOrStopBtn(hwnd,FALSE);
Sleep(1000);
s_pCtl->SetWindowText(_T("开启所有端口,等待8秒"));
OnClickStartOrStopBtn(hwnd,TRUE);
Sleep(8000);
}
}
if(10 == i)
{
AfxMessageBox("开启十连败,请手动调整机器");
return FALSE;
}
s_pCtl->SetWindowText(_T("所有端口开启成功"));