How to Abort a Callback Function While It's Running in LabWindows™/CVI™

Updated May 15, 2019

Reported In


  • LabWindows/CVI

Issue Details

I am not able to stop the program or click any other buttons while the for loop is running. How do I fix this?


  1. Use a Toggle Button instead of a Command Button for the Stop button.
  2. In LabWindows/CVI, once a callback is entered, user interface buttons are ignored until you return from the callback, unless you call ProcessSystemEvents().

  3. Read the Stop button value using GetCtrlVal in the loop in the callback for the Run button.  Stop does not need its own callback.
See the example of the code below:

Additional Information

Another way to achieve this could be to drop a timer control on your UIR and set its interval to be 1 second.  This timer control will call a routine in your code at the interval you define.  Then, you just enable or disable the timer from the callbacks for the run button and stop button.