LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Queue Refnum Invalid After Enqueue from Event Case

Solved!
Go to solution

Hi all,

I'm facing an issue with queues in LabVIEW, and I need help understanding what I'm doing wrong.

My Architecture

  • I have a Queue Manager implemented as an FGV.

  • On initialization, I create multiple named queues and store their refnums inside the FGV.

  • After initialization, I can read all queue refnums and they are valid (probed output from the FGV).

  • Different parts of the application enqueue to these queues, and another loop dequeues them.

The Problem

Whenever I enqueue data inside an Event Structure (or even from another subVI), the enqueue function fails.

  • The error I get is something like:
    “<Queue Name> does not exist”
    or
    “Not a refnum” or Enqueue Element in Controller Enqueue.vi->Main screen.vi->Main screen.vi.ACBRProxyCaller.4DE0000C

  • Probing the queue wire at the Enqueue node shows “Not a Refnum”.

  • But when I open my Init subVI, all queues are created properly and the FGV still outputs valid references.

Important Notes

  • The Queue Manager FGV works perfectly right after INIT — all queue refs are valid.

  • The issue only appears after an Event Case enqueues OR when a different VI tries to dequeue.

  • If I bypass the event structure and call enqueue directly, same issue occurs sometimes.

  • No Release Queue is called anywhere except on application exit.

  • This happens even though I use named queues and always request refs from the FGV.

What I Need Help Understanding

Why does the queue refnum become invalid (Not a Refnum) when:

  • Enqueue is called inside an event case, OR

  • Enqueue/Dequeue is called from another VI?

Is this a wiring/tunnel issue in the Event Structure, or a reentrancy issue, or something wrong with using an FGV as a queue manager?

Any suggestions or examples of proper multi-queue management with FGVs would be greatly appreciated.

Thanks in advance!


Screenshot 2025-11-26 124708.pngScreenshot 2025-11-26 125140.png

0 Kudos
Message 1 of 18
(285 Views)

Hi shangchi,

 


@shangchi wrote:
  • I have a Queue Manager implemented as an FGV.

  • On initialization, I create multiple named queues and store their refnums inside the FGV.

  • After initialization, I can read all queue refnums and they are valid (probed output from the FGV).

  • Different parts of the application enqueue to these queues, and another loop dequeues them.

What I Need Help Understanding

Why does the queue refnum become invalid (Not a Refnum) when:

  • Enqueue is called inside an event case, OR

  • Enqueue/Dequeue is called from another VI?


  • Where do you do that "initialization" of the queue references?
  • I suspect a race condition: you read the "q ref" before the message handle loop, but the FGV read operation has NO DATA DEPENDENCY and so it will run (most probably) right after start of the VI! Is the FGV already initialized before you read the ref?

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 18
(260 Views)

Q initializing VIQ initializing VIq initialising is in this vi and and it lauch main vi asynchronously. in main vi i created a panel closing event at that time the i enqueue "exit" state to the previously created q namely " controller" and it will be dequeued in controller vi and goes to exit stateq initialising is in this vi and and it lauch main vi asynchronously. in main vi i created a panel closing event at that time the i enqueue "exit" state to the previously created q namely " controller" and it will be dequeued in controller vi and goes to exit state

0 Kudos
Message 3 of 18
(250 Views)

Hi shangchi,

 


@shangchi wrote:

q initialising is in this vi and and it lauch main vi asynchronously. in main vi i created a panel closing event at that time the i enqueue "exit" state to the previously created q namely " controller" and it will be dequeued in controller vi and goes to exit stateq initialising is in this vi and and it lauch main vi asynchronously. in main vi i created a panel closing event at that time the i enqueue "exit" state to the previously created q namely " controller" and it will be dequeued in controller vi and goes to exit state


As suggested before: there is a clear RACE CONDITION between your "INIT" VI and the "Q Manager" FGV call where you read the "Controller" queue ref!

 

Solution: call the FGV AFTER you call the INIT VI. Use wires to enforce DATAFLOW…

 

(Most problems are solved in LabVIEW by "THINK DATAFLOW!"…)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 18
(224 Views)

Thanks for the response. I tried accordingly but when I run the program on the first try it won't execute as expected but if I abort and run again, it will execute without errors.

0 Kudos
Message 5 of 18
(152 Views)

Hi shangchi,

sounds that you still have a race condition. That it workes second time, can indicate that the queue refnums are not closed correctly in first run, so they are still available in second run and already open.

_________________________
using LV 2025 Q3
Message 6 of 18
(136 Views)

@MECSO wrote:

Hi shangchi,

sounds that you still have a race condition. That it workes second time, can indicate that the queue refnums are not closed correctly in first run, so they are still available in second run and already open.


Especially the part about it working after it aborted. Things don't get closed when the VI is aborted.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
Message 7 of 18
(110 Views)

But in some Vis the Q is read without error. The error is on the "Panel Close" event. while panel close im sending "process kill" to another vi and from there all vis will be stopped. This is the scenario. Im launching 3 vis and dequeuing ststes without error but while panel close event happens - the Q is not read poperly!

shangchi_0-1764243216936.png

 

0 Kudos
Message 8 of 18
(94 Views)

Hi shangchi,

 


@shangchi wrote:

The error is on the "Panel Close" event. while panel close im sending "process kill" to another vi and from there all vis will be stopped. This is the scenario.


Again: RACE CONDITION!

 

You call that "Exit Main" subVI, that seems to flush/release the queues. And (again) you call a subVI without enforcing execution order using DATAFLOW!

 


@shangchi wrote:

But in some Vis the Q is read without error.


"Some VIs without error" is an indication of race conditions: sometimes the code may work, othertimes it may fail…

 

Did you even try to debug your FGV?

Can you verify WHEN you release the queues and WHEN you call the FGV with it's "read" command?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 9 of 18
(90 Views)

This is vi where the Q is read and dequeued for the corresponding sates (now - EXIT) 

shangchi_0-1764244069737.png

 

0 Kudos
Message 10 of 18
(84 Views)