Example Code

Stop an Event Structure from Queuing Events 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 Stops an Event Structure from Queuing Events

 

Description

Say you have an event case triggered by the value change of a Boolean button. Say the event takes 2 seconds to finish. If you click the button 5 times in those 2 seconds, the events will be queued and will execute 5 times. So there’s no way to stop the event structure from queuing events, but you can change how the duplicate events are handled, by using a producer/consumer events pattern.

In this code, when the Increment event fires, it changes the Panel Blocked Boolean to True and alerts the consumer loop to perform the incrementing event. Now that Panel Blocked is True, any other Increment value changes will not be queued and sent to the consumer loop. So, the duplicate events are ignored (not by the event structure, but by the consumer loop). When the Increment case in the consumer loop is finished executing, a dynamic user event is fired, changing Panel Blocked back to False. By handling events this way, we are handling them asynchronously.

 

Requirements

LabVIEW 2012 or compatible

 

Steps to Implement or Execute Code

  1. Run the VI
  2. Press Increment button
  3. Notice that the Panel Blocked Boolean changes to True

 

Additional Information or References

VI Block Diagram

Stop an Event Structure from Queuing Events Using LabVIEW BD.jpg

 

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

Product Support Engineer
National Instruments

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

Comments
RoyA
Member
Member
on

You could do the same thing by using a 'Disabled' property node for the control while the event is executing.  You could also use 'Set Busy.vi' and 'Set Unbusy.vi' to turn the cursor into the hourglass to let the operator know something is going on.

Roy

New update:  You don't need the Disable property node.  The 'Set Busy.vi' apparently disables FP inputs all by itself.  I couldn't click on anything, or Tab-Spacebar.