y****h 发帖数: 188 | 1 ms visual studio.net, C++ MFC Dialog下编程。
由个框可以填iteration time,另外有还有个stop button。
程序内容是个大型计算(其实也不怎么大啦,只不过你能觉察出运算时间),
iteration设的越大,时间就花得越多,所以我加了个stop钮,以期在我觉得
运算时间太长时,停止运算,回来设个小点的iteration重新算。
我的做法是给botton加了个BN_CLICKED的event control, 再在它的control ID
下加了个m_boolStopSign的variable, 缺省值为FALSE, 当点击这个键的时候,
m_boolStopSig变为TRUE,然后在计算的循环里加了
if(m_boolStopSign)
break;
希望以此来中止计算。但试了以后,好像不行。我不知道是不是因为在计算loop
执行过程中,界面上的所有操作都不被响应?我还想在loop执行到第i步iteration
时把相应的i显示在一个框里(m_intIterationTime=i; UpdateData(FALSE);),
结果也是 | y****h 发帖数: 188 | 2 再看了一下,是不是非用线程控制不可啊?
【在 y****h 的大作中提到】 : ms visual studio.net, C++ MFC Dialog下编程。 : 由个框可以填iteration time,另外有还有个stop button。 : 程序内容是个大型计算(其实也不怎么大啦,只不过你能觉察出运算时间), : iteration设的越大,时间就花得越多,所以我加了个stop钮,以期在我觉得 : 运算时间太长时,停止运算,回来设个小点的iteration重新算。 : 我的做法是给botton加了个BN_CLICKED的event control, 再在它的control ID : 下加了个m_boolStopSign的variable, 缺省值为FALSE, 当点击这个键的时候, : m_boolStopSig变为TRUE,然后在计算的循环里加了 : if(m_boolStopSign) : break;
| y****i 发帖数: 156 | 3 Yes, when you have a long loop in main thread. The UI will not respond to
event.
Create a thread to do the longtime computation.
【在 y****h 的大作中提到】 : 再看了一下,是不是非用线程控制不可啊?
| g****c 发帖数: 299 | 4 parent thread manage job controling , child thread running job
【在 y****h 的大作中提到】 : ms visual studio.net, C++ MFC Dialog下编程。 : 由个框可以填iteration time,另外有还有个stop button。 : 程序内容是个大型计算(其实也不怎么大啦,只不过你能觉察出运算时间), : iteration设的越大,时间就花得越多,所以我加了个stop钮,以期在我觉得 : 运算时间太长时,停止运算,回来设个小点的iteration重新算。 : 我的做法是给botton加了个BN_CLICKED的event control, 再在它的control ID : 下加了个m_boolStopSign的variable, 缺省值为FALSE, 当点击这个键的时候, : m_boolStopSig变为TRUE,然后在计算的循环里加了 : if(m_boolStopSign) : break;
| r*******q 发帖数: 50 | 5 There is a way need not threading. But it's not a good way...
【在 y****h 的大作中提到】 : 再看了一下,是不是非用线程控制不可啊?
| y****i 发帖数: 156 | 6 //////
static MSG msg;
while (::PeekMessage(&msg,NULL,0,0,PM_NOREMOVE)) {
if (!AfxGetApp()->PumpMessage()) {
::PostQuitMessage(0);
【在 r*******q 的大作中提到】 : There is a way need not threading. But it's not a good way...
|
|