From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
This question gets asked like a bijillion times a month. Did you try a search? You need a loop that sits there waiting for the user to press the button. (Note: the only thing that should be in the loop is the actual operation. One-time configurations should be outside the loop. Same goes for closing the resources.) A simple state machine is an ideal solution. I'd recommend reading this article: Application Design Patterns: State Machines