Example Code

Dynamically Call Multiple SubVIs From a Queue

Code and Documents

Attachment

This example shows how to use a producer\consumer design pattern with a queue to dynamically call multiple subVIs. The subVIs are called and then run independently of Main.vi. This means that they are running but Main.vi does not wait for them to finish executing before continuing (they are non-modal).  This is useful if you want to create a scalable solution for having multiple popup windows while still allowing the main part of the program to run.

The Main VI has two buttons that will call two separate subVIs.  The first subVI shows the amount of time that has elapsed since it was called.  The second subVI generates and displays a random number.

In this example, user events add subvis to a queue that will be called in the consumer loop.  In other applications, any type of event (i.e. programatic event) can add a subVI to the queue.

Main VI:

Main_Block_Diagram.png

SubVI:

SubVI_Block_Diagram.png

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
JUSTBEGINE
Member
Member
on

hey can u share the procedure please how to do the above task?

 

Contributors