From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Example Code

Producer Consumer Loop with Programmatically Triggered Enqueue Using LabVIEW

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

Download All

Overview

This VI is a template that build a producer/consumer design pattern with events to produce queue items.

 
Description

This VI takes the Producer Consumer Loop and programmatically adds an element to the Queue the first iteration.  This VI takes the Programmatically Trigger Events Example and put it into a Producer Consumer Template.

Use this design pattern instead of the User Interface Event Handler pattern for user interfaces when you want to execute code asynchronously in response to an event without slowing the user interface responsiveness.


Requirements

  • LabVIEW 2012 (or compatible)


Steps to Implement or Execute Code

  1. Run the VI.
  2. Click the rocker to Enqueue an item.
  3. Notice how the first time the rocker is pressed it goes to 2 because 1 element was automatically Enqueued.

Additional Information or References
VI Snippet

004.png

**This document has been updated to meet the current required format for the NI Code Exchange.**

Applications Engineer
National Instruments

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