How Do I Immediately Stop a Loop While it is in Wait?

Updated Mar 22, 2018

Reported In


  • LabVIEW

Issue Details

I have a for loop in LabVIEW that I am using to cycle through a case structure. I want each case to wait for a hundred seconds before moving onto the next case structure, to do this I use a wait(ms) sub VI. The problem is if I try to stop the VI it finishes the duration of the wait before it stops. How do I make it stop right when I press stop? 


One way to solve this issue is to avoid long-running wait function calls. Instead of running one long wait you use a for loop to run many shorter waits. You can then add a conditional terminal into your for loop and place the local variable for your stop button inside of it, that way the for loop will stop running if you stop the VI.
Above you can see an example. Instead of waiting for a hundred ms, you can use the for loop to wait for one ms a hundred times.