简体   繁体   English

停止功能循环然后恢复它们

[英]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. 在我的主要设备中,我有2个主要功能分支,其中一个仅在程序启动时运行一次(一种带有Windows / overlay / mousecallbacks的开始菜单),另一种则是循环,包括相机,阈值,蒙版,旋转,图像处理等。其他功能。 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. 问题是,我希望能够停止循环,显示带有2个按钮的“暂停菜单”,在其中我将为“恢复并退出”按钮添加鼠标回调功能。 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. 我将C ++与Opencv库一起使用。

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. 如果用户想继续,则该函数返回另一个值,您只需继续循环即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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