Re: [gtkmm] handling signals within a signal handler?



>void on_go_button_clicked() {
>  for (int i=0;i<500;i++)
>    // do something CPU intensive here
>}
>
>The problem is this function takes about 3-5 minutes to complete, and during 
>that time, the GUI is completely unresponsive, and it appears to the user that
> 
>the application has crashed.  Ideally, I would like to run maybe 1-5 iteration
>s 
>and then check for GUI button presses (such as a STOP button that would break 
>out of the loop).  Can this be done w/o using multiple threads??

with easily block-ified workloads like this, you can run your code
from the idle loop by registering an idle handler/callback. run your
iterations, then return TRUE if there is more work to do, FALSE if the
work is done.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]