Error 1122 When Using Queue Functions

Updated Nov 16, 2023

Reported In


  • LabVIEW Base
  • LabVIEW Full
  • LabVIEW Professional

Issue Details

When I use an Enqueue Element, Enqueue Element at Opposite End, Preview Queue Element, Preview Queue Element, or Dequeue Element, I get:

Error: 1122 Refnum became invalid while node waited for it.

How can I resolve this?


To avoid this error, make sure that all processes or threads that reference a queue are stopped prior to releasing the queue reference.  Modifying the above design template to use notifiers as well as queues demonstrates one way of ensuring that error 1122 is not thrown.

The notifier transmits the status of the Stop button to the consumer loop.  The Merge Errors node ensures that both producer and consumer loops have stopped before the queue reference is released.

Note:  This code will hang if there is no timeout argument provided to the Dequeue Element node.

Additional Information

This error commonly appears when one of the previously listed Queue functions or operations tries to operate on a reference which has been closed. Always ensure to close the reference only after all other functions needing it have executed. Also note that this reference only needs to be closed once. 

The Producer/Consumer Design Pattern (Data) available from LabVIEW relies on this error being thrown to stop the Consumer loop — when the stop button is clicked, the producer loop exits and the queue reference is released.  The next iteration of the consumer loop attempts to de-queue from a queue reference that has been released, which throws error 1122, and stops the loop.