Example Code

Communicating with an Asynchronous Call VI

Community Verified

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

Description

Many LabVIEW applications require communication between asynchronous processes running in parallel. One of the most common scenarios is a VI that launches another VI asynchronously, and then those two VIs need to communicate. There are many ways to communicate between parallel asynchronous processes in LabVIEW. One of the most common ways is with User Events, as demonstrated by this example (saved in LabVIEW 2016). 

 

blobid1685734842198.png

 

Bi-directional communication between the Main VI and the Async VI is accomplished simply by creating two User Events... one that the Main VI uses to send events to the Async VI, and another that the Async VI uses to send events to the Main VI.

 

Also note that communication between parallel asynchronous processes is built-in to LabVIEW frameworks like Actor Framework (which uses queues) and DQMH (which uses events, similar to this example). When using these frameworks, all of this communication is handled behind the scenes and wrapped in higher-level APIs, abstracting away the tedious nature of programming VI Server, events, and queues, so you don't have to.

 

If this example were implemented with DQMH, the structure of the Main VI would largely stay the same, but the the Async VI would be implemented as a DQMH Module, and you would use the Public API of the module to start the module and send requests to it, while the Main VI would be registered for broadcasts from the Async VI Module. Most importantly, the VI Server and raw event code in the Main VI would go away and be replaced with much simpler calls to the Async VI Module's Public API.

 

Related Links

Design Considerations in LabVIEW

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

Contributors