| 发表于:2007-03-13 20:29:52 楼主 |
线程定义函数: uint ctwothreaddlgdlg::cthreadproc(lpvoid pparam) { ctwothreaddlgdlg* pparent=(ctwothreaddlgdlg*)pparam; static int a=0; cstring str; volatile int nnum; //调用等待启动事件,如果没有启动事件信号将一直等待下去 ::waitforsingleobject(m_begin,infinite); //如果用非模态对话框,编译能通过,也能显示对话框,但程序会死掉 newdlg* pdlg=new newdlg; pdlg-> create(idd_dialog1,null); pdlg-> showwindow(sw_show); //如果用模态对话框,程序能顺利运行 //newdlg pdlg; //pdlg.domodal(); //开始计数 for(m_count=0;m_count <80000;m_count++) { str.format( "%d ",a); pparent-> m_edit.setwindowtext(str); a++; for(nnum=0;nnum <50000;nnum++) { } //调用等待停止事件,由于超时值为0,所以只进行简单的判别作用 if(::waitforsingleobject(m_end,0)==wait_object_0) break; } //告诉主窗口线程已经结束 ::postmessage(*pparent,wm_finished,0,0); return 0; } |
|
|
|
|