Example Code

Event versus Polling in 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 code allows the user to realize about the performance of the Events and the Polling.

 

Description

Event Structures are often the most efficient method of creating a reactive user interface.  This VI demonstrates the difference in CPU usage between polling for user input in a loop and using an Event Structure to respond to events.  Run the VI and choose not to use the Event Structure , then pull up the Task Manager in Windows and monitor the CPU usage.  It should max out one CPU core.  Choose different buttons and see the reactions.  Then choose to use the Event Structure, and see the CPU usage drop, but notice that the buttons respond just as quickly.

 

Requirements

LabVIEW 2012 (or compatible)

 

Steps to Implement or Execute Code

  1. Run VI
  2. Watch the Task Manager and see the CPU difference
  3. Click on Use Event Structure to switch between Event and Polling

Additional Information or References

5103.png

 

Developing User Interfaces with Event-Driven Programming

Event-Driven Programming in LabVIEW

 

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

Seth B.
Principal Test Engineer | National Instruments
Certified LabVIEW Architect
Certified TestStand Architect

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

Comments
robert.hovakimyan
Member
Member
on

that is not honest... you will see the same result putting 0 Event Timeout . Otherwise you should add 50 timing delay in False case, which also bring to a same result.