LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Exit from two While Loops in one VI

Hello Everyone,
 
I am developing one application in LabVIEW 8.2.
I have 2 while loops running in parallel.
One while Loop is having an Event Strurture in it for handling the User events and other while loop is handling a notification of sending some data on the communcation line.
 
My problem is that I want to exit from both the while loops when User either clicks on the "Stop" Button on the GUI. this should stop that other while loop also.
Also in the second while loop, if the nitifiaction is received then i have to stop the second while loop and this has to stop the while loop of the the event struture also.
 
I have currently having indicators at the exit terminal of both the loops and checking the status in the other while loop.
 
Is there any other optimised solution for the same???
Please help me for giving me the best optised solution which will help in my case..
 
Thanks a lot in adavnce
Hoping to get a good help from all LabVIEW Experts.
 
Regards
Avni Vyas
 
0 Kudos
Message 1 of 6
(3,444 Views)
Could you please attach your vi so that I can see exactly what you are describing.  If I am understanding you correctly, you could add an event tied to a stop control that is wired to the stop terminal of the while loop that contains the event structure.  You could then wire the error cluster directly to the stop terminal of the second while loop.

Cheers!
0 Kudos
Message 2 of 6
(3,435 Views)
It would always be much easier to attach a small VI.
 
You can place the stop button in the loop that has no event structure, wired directly to the loop termination terminal. In the event loop create an event that senses the stop button and stops the loop. If the other loop stops whithout user interaction, you can fire the stop event via a value(sgnl) property after the loop has completed.
 
0 Kudos
Message 3 of 6
(3,432 Views)

Hi avni,

close the refence of your notification after the while loop with the event structure in it. In the other while loop with the notification receiver in it, connect the error output of the receiver with the loop condition. If you close the notification reference the output of the receive function is an error and stops the loop. If you receive the stop condition over the notification you can change the value of your stop button with the property "value (signaling)", than it will stop your vi in the same way as you click the stop button. First the event loop stops -> than the notification will destroyed -> than the receive loop will be stopped.

Mike

0 Kudos
Message 4 of 6
(3,425 Views)

Hi avni,

here is an example of what i said in the text.

Mike

0 Kudos
Message 5 of 6
(3,418 Views)
It might also be possible to do everything in one loop. Maybe you can do the notifications in the timeout event of the event loop.
 
(It really depends on details of your code that we don't now.)
0 Kudos
Message 6 of 6
(3,416 Views)