65,187
社区成员




void CThreadTestDlg::OnButton1()//启动线程
{
// TODO: Add your control notification handler code here
DWORD ThreadId;
handleThread=::CreateThread(NULL,0,TestThreadProc,this,0,&ThreadId);
}
void CThreadTestDlg::OnButton2()//关闭线程
{
// TODO: Add your control notification handler code here
TerminateThread(handleThread,0);
}
DWORD WINAPI CThreadTestDlg::TestThreadProc(LPVOID lParam)
{
CThreadTestDlg *mainDlg=(CThreadTestDlg*)lParam;
int iMsg=0;
for (int i=0;i<65536;i++)
{
iMsg++;
mainDlg->OnShowMsg(iMsg);
}
return 0;
}
void CThreadTestDlg::OnShowMsg(int iMsg)
{
m_strMsg.Format("%d",iMsg);//m_strMsg为Edit控件绑定变量
UpdateData(FALSE);
}