I know couple methods to run-pause-stop code which allow to do in parallel other things like realtime graphics and opening other menu items with working code doing other things.
One method is simple and almost perfect, but is not 100% reliable, while the second is 100% reliable but a bit too tricky to make a short demo out of my head, i am not quite getting its trick so i quickly forget it. I use both and will shortly describe them here. Now i am running out of time to search details but when time will allow i may find the demos.
Method 1. The GUI could be pretty complex and have hundreds callback for doing different things. If you will start all of callback functions with the Permit_another_callback@ then things go OK unless you by mistake hit the button several times too fast. Then this button will stop reacting. Rarely happening. And the amount of times another callbacks are permitted could be millions, no problems here. You can use buttons and radiobuttons and also in parallel the accelerator keys, by some reason they sometimes work when other fail. This method was promoted by Paul.
Method 2 needs short sample to show it. You create as usual the buttons (Run, Pause, Stop) with callback functions but the trick is to interrupt the source code of your GUI with additional subroutine which will have small part of the same GUI. This subroutine has to create window which will be permanently open during the run. All that looks like impossible even to comprehend but with the Clearwin this somehow works. Additional window can do nothing useful or do passively something like displaying elapsed CPU time, some menus etc. This method described me John Appleyard from Polyhedron two decades ago and it is the most bulletproof as it never failed in its everyday torture. If urgent, you can ask him
I published small reproducers of two or even three of such methods few times in this forum in the past, so you can search this forum using my name and keywords 'Permit_another_callback@', 'Appleyard', 'Run-Pause-Stop', 'multitasking' etc