If you are using LabVIEW 2016, you can use channel wires to stop multiple parallel While Loops with one stop button. This is possible because channel wires are asynchronous wires that connect two parallel While Loops without forcing an execution order. Hence, no data dependency between the two parallel While Loops.
Note: Channel wires are supported by the LabVIEW Real-Time Module but not the LabVIEW FPGA Module.
The following block diagram demonstrates stopping parallel While Loops using a Tag channel:
The following list describes important details about the previous block diagram:
The following block diagram demonstrates stopping parallel While Loops using a Stream channel:
When using Stream channels, the stop button wired to the last element parameter of the writer endpoint in Loop A communicates with Loop B.
The Tag channel and the Stream channel have major differences when used to stop parallel While Loops.
You cannot extend the previous Tag architecture to have multiple stop buttons. However, you can add one or more stop buttons using the Share Stop Signal VI located in labview\vi.lib\ChannelSupport, which allows you to stop multiple parallel While Loops with any one of the stop buttons.The following VI snippet demonstrates stopping multiple parallel While Loops using either of the two stop buttons. To add more stop buttons, follow the same architecture.
You can stop multiple parallel While Loops with one stop button by passing the Boolean stop button value from your first loop's control to all of the other loops using a local variable for each additional loop. The following block diagram demonstrates stopping two parallel While Loops using a local variable.
To stop more than three parallel While Loops, follow the same architecture by adding more local variables to read from the initial stop control.
You can use a property node to pass the Boolean stop button value from your first loop's control to all of the other loops. The following block diagram demonstrates stopping two parallel While Loops using a property node.
To stop more than two parallel While Loops, follow the same architecture by adding more Value property nodes to read from the initial stop control.
For more information about when to use a local variable versus a property node, refer to Difference Between a Local Variable and A Value Property Node Article.
For applications that involve complex behavior, notifiers can be used to stop multiple loops running in parallel. The notifier functions are accessible from the Programming»Synchronization»Notifier Operations palette.
Note: The use of notifiers scales easily to multiple threads, but does not always integrate well with existing program architectures.
The following VI snippet demonstrates one way notifiers can be used to stop multiple While Loops.
The following list describes important details about the previous VI snippet:
Note: Ensure that the notifier is not released until all the threads monitoring it are stopped. In the previous VI snippet, the Merge Errors VI guarantees that the Release Notifiers VI will not execute until all loops stop.
You can use queues to stop multiple loops running in parallel for applications that involve more complex behavior. The queue functions are accessible from the Programming»Synchronization»Queue Operations palette.
Note: Many larger applications already have a queue system in place to exchange data between parallel loops. In these setups, the existing queue may be modified or enhanced to include a stop instruction for parallel loops.
The following VI snippet demonstrates using queues to stop multiple While Loops:
Some applications using a Master-Slave architecture release the queue before the slave threads exit. The error thrown from dequeueing from a destroyed reference is then used to stop the slave loops. In lieu of relying on an error condition to stop the slave loops, the previous VI snippet has a discrete stop instruction that is passed on to the slave loop from the master loop.
Collaborate with other users in our discussion forums
A valid service agreement may be required, and support options vary by country.
Thank you for your feedback.
You changed your response to Not Helpful
You changed your response to Helpful