06-25-2012 05:04 PM
Hi, I hope you can help me.
I have a loop and inside this loop I have all my program. When I want to stop the loop I have to wait at the end of one execution of the loop. My question is, how I can stop my loop at any instant using a button like control?
06-25-2012 05:21 PM
You can't cleanly stop a loop iteration in the middle of an iteration. I would suggest that you use a producer/consumer architecture with the producer controling the UI portion of your application. At a minimum you can at least inform the user that you are processing their stop command. The consumer would be a state machine and hopefuly no single state of your state machine would require a very long time to execute. Using this type of architecture you should be able to repond to the shut down in a reasonable time.
06-25-2012 07:12 PM
What Mark said. Also, if your program uses timers in the form of hard Wait(ms) functions, you can switch to to an interruptible timer of your own design, or use the Elapsed Timer Express VI.