I use the template user interface. I then put a loop(simple index indicator) with stop button, inside the button event. If I click the button, the loop starts. Then I click the button one more time. I have to click the stop button twice to stop the loop. How can I make it not to queue my click?
Solved! Go to Solution.
I limit the maximum instance to 1. If I click the "command 1" twice, I have to click twice the "stop button" to stop the loop. Is it a bug? I am using labview 2015.
It is a bug in the implementation of your code. You do not want a long running while loop inside of the event case.
It is not a bug in LabVIEW. It is queueing up only one event. You hit the button, the event case starts executing pretty quickly and removes that event from the queue. Now it needs to wait for you to hit stop to kill the while loop inside. If you hit Button 1 again, it queues up that event and you now have 1 in the queue again. So when you finally hit stop, it ends the first execution of the event. The newly queued up one now runs, and you have to hit stop in order to stop that.
A producer/consumer architecture with events is a better architecture for this. You could also get rid of the while loop, move the desired code into the timeout case. Use a shift registers to change the timeout from -1 to 0. Have an Stop button event that sets the timeout value back to -1.
Thanks for your reply. I am wondering.... why labview cannot make the click/event instance removed after the things in the event is done......
Because that is not the way it was designed. The intention is to limit the number of events that are held in the queue, and discard the older events in case it overruns that limit.
How can you discard the oldest event if you have already begun executing it? Technically, the first thing that happens when the event case runs is that it removes the event from the queue so that it can begin operating on it.