Example Code

Producer/Consumer Architecture with Keyboard Input 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

Overview

This VI shows how to use the producer/consumer architecture to queue up keyboard inputs in the producer loop and perform actions based on the input in the consumer loop.

 
Description

Use this template to build a producer/consumer design pattern with events to produce queue items. 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, press the "F" key will toggle the indicator and wait for 1 second.
  2. If you press the "F" key faster than once per second, the presses are queued up to demonstrate that no input is lost.

 

Additional Information or References
VI Snippet

004.png 

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

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