The following example shows the recommended way to handle a latched stop Boolean control in the Event structure. The Event structure is inside a While Loop and one case of the Event structure is configured with a Value Changed event for the stop Boolean control. When the value of the stop Boolean control changes to TRUE, the Event structure executes that event case, which reads the front panel terminal to reset the stop button. The stop Boolean control is wired to the While Loop conditional terminal, which stops the loop.
A common mistake is not to configure an event case to handle the stop latch Boolean control. If you do so, the first time the While Loop executes, the While Loop reads the stop button value and evaluates the loop termination condition, which is FALSE. The Event structure then executes and waits on an event. The user clicks the stop button, which generates an event and triggers the Event structure. The case configured to handle the event executes. The While Loop repeats and evaluates the terminating condition, which is TRUE this time and tells the loop not to execute again. The Event structure executes and waits for the next event. The user clicks the stop button one more time and triggers the Event structure, which executes the correct case. The loop finishes executing, and the VI finishes running.