Showing results for 
Search instead for 
Did you mean: 

Elegant Solution to Stop Parallel VI

I am interested in an elegant way to stop a VI that is running completely parallel, when the main VI is terminated.

In this example sub-VI is used to control the color of tabs in a Tab control. I create and pass a rendevous refnum to the sub-vi. To stop the sub-vi, I kill the rendevous refnum, and monitor for an error in the sub VI.

I realize I could use a global, but I am trying to find something better (to many globals complicate a big project), but if a global is the right way, maybe I should use that?

(FYI top vi is test tab color. Sorry for the large lib, those open source poly vi's really spam the file :).
0 Kudos
Message 1 of 8
0 Kudos
Message 2 of 8
0 Kudos
Message 3 of 8
Sorry bout that - I am used to the old days when creating a library file did not strip the diagrams,
0 Kudos
Message 4 of 8
When you saved the LLB it seems that you have used "Application Distribution" which indeed removes the block diagrams by default. If you use "Development Distribution" the block diagram will be included and all VIs from vi.lib will be excluded. I'v got some problems since the Rendezvous VIs are in the LLB but the lsb file is missing there.

We often use a multi threaded software architecture. Dependend from the developer we use two methods stopping all the threads.
One is the same you do destroying the synchronisation object and checking the error cluster.
The other one uses named queues. There is one thread responsible for starting and stopping the application. It sends a "Stop" message to all the other threads and they are able to send a "Done" message back and then the application exits.

The first way has the problem that the VI destroying the synchronisation object has no chance to know when the other VIs are really ready. If they have to do some cleanup like writting and closing files, stopping DAQ task ... they maybe not be able to do it. Think that your main VI will have a Exit LabVIEW function behind the Destroy Rendezvous VI your application is gone and no cleanup is possible.

Using 7.1.1, 8.5.1, 8.6.1, 2009 on XP and RT
Don't forget to give Kudos to good answers and/or questions
Message 5 of 8
Thanks for the response (I could not rate it - there were no "Ratting" buttons at the bottom!)

It was a good answer, but I am curious about the mechanisms used to "Pass" your messages. I can think of only a few ways to do it (without getting complicated, like TCP/IP functions, Data Sockets, etc). Passing a control reference (or app refnum, and then expecting the thread to identify the control) or using global variables.

What other methods are well suited to message passing?
0 Kudos
Message 6 of 8
In order to rate the response you have to be signed in. Once your signed in the Rate this message will appear at the bottom of each message.
0 Kudos
Message 7 of 8
Hey Scott,

Use the 'Queue functions' to pass the messages between the parallel instances. This will be much more efficient than using Global Variables. You can pass the Queue reference to the SubVIs and that way access the same queue from many different levels of your code. Please try my small example that shows how to pass a Queue to a subVI.

Have fun!
- Philip Courtois, Thinkbot Solutions

Thinkbot Solutions
0 Kudos
Message 8 of 8