c++ - Programming problem with a continuous loop and buttons? -


i have design program uses main loop keep track of time , perform continuous checks. have gui system can alter things in system. question is:

if run continuous loop doesnt stop until system exits, user able interact gui have set up, or loop have stop running effect of pressing button take place? in other words, have pause loop, run button command, restart loop, everytime user interacts gui? , if so, there way around this? , answer

since didn't state platform, term reply generically.

there 2 patterns can use: polling or interrupt / event driven.

polling

the polling involves checking semaphore or flag see if happened. common in embedded systems. background loops until interrupt sets flag processes event.

interrupt / event driven.

in pattern, function executed when event occurs. example, function may executed when user clicks on button.

on desktop platforms (mac, linux, windows, etc.), situation resolved using multiple threads (of execution). gui operation on 1 thread , main processing on another. allows program not freeze gui when button clicked.

on application, gui sets event when user clicks button. processing thread waits (sleeps, pends) on event. user clicks button, event set. processing thread wakes , continues.


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -