简体   繁体   中英

Stopping a loop of functions then resuming them

I have a rather long code so I will only post if necessary, but i will thoroughly explain the problem.

Inside my main i have 2 main function branches, one that runs only once when the program starts (sort of a start menu with windows/overlays/mousecallbacks) and a loop one, with camera, thresholding, masking, rotation, image processing and some other functions. The thing is that I want to be able to stop the loop, show a Pause Menu with 2 buttons, where I will add the mousecallback functions for a Resume and Quit button. Quit is rather easy to do but resume isnt. Ok ok, so my question. How do I stop the loop in order to open a new page, and then from that page resume the loop where it was before?

Inside this page i will not need any of the functions inside the loop, so i am guessing there has to be a way to stop it, then resume it using mouse input.

I am using C++ with Opencv libraries.

Any suggestions are welcome.

In the main loop, call a function which blocks execution while waiting for an answer from the user. Modal dialogs can be used for this.

If the user wants to exit, then the blocking functions return a special (possibly boolean) value that can be checked, and you exit the loop. If the user wants to resume then the function returns another value, and you simply continue the loop.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM