Example Code

Move LabVIEW Window Using Producer/Consumer Loops

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.


  • LabVIEW

Code and Documents



This example shows how the Producer/Consumer architecture can be used to take in and process user events. The outcome of the program is that the LabVIEW window will move onscreen based on user inputs. 


This application has a user interface with four directional control buttons and a queue status indicator. The block diagram has one loop that collects user interface events and updates the queue indicator (Producer loop), and another loop that takes the user interface data and moves the window accordingly (Consumer loop). This example makes use of the buffered communication in Queue Operations functions






How to Use

  1. Open the attached code Move-Window.vi. 

  2. Run the program.

  3. Press the Up, Down, Left, and/or Right buttons.

    • These commands are captured in the Producer Loop. The Consumer Loop processes the commands.

  4. Press the front panel buttons quickly.

    • The queue on the front panel shows the commands in the order that the buttons were pressed. As the commands are processed in a first-in/first-out manner, the queue updates.

  5. Press Stop to complete the program.

    • In this program, Stop halts all window movements, and commands are left in the queue. It is possible to alter the program so that the queue is emptied (i.e. commands are executed) before the program stops running.


Technical Support Engineer
National Instruments

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