07-25-2011 11:52 AM
I have an infinite loop getting and displaying data. How can I halt the loop with a button or keypress?
Solved! Go to Solution.
07-25-2011 03:50 PM - edited 07-25-2011 03:56 PM
Periodically perform a ProcessSystemEvents() call inside your loop. In a STOP button callback, set a flag to tell your loop to stop.
unsigned int stop = 0;
while (!stop) {
getmeasured data
display data
ProcessSytemEvents()
Sleep (250); // to be polite: it's rude to spinlock, since you'll hog the CPU and other threads can get starved
}
then, in the callback for a STOP button
// STOP button Callback routine
stop = 1;
07-26-2011 09:06 AM
Works. Thanks.
07-26-2011 09:43 PM
You're welcome.