Showing results for 
Search instead for 
Did you mean: 

Generated user events ignore loop timer

Go to solution

Hello LabView folks,

Im relatively new to LabView and am trying to unterstand user events at the moment.

The small VI I attached creates a user event called 'Event' which is a simple string. The event is registered in two while loops with event structures. When the button OK is pressed two user events are generated ('aaaa' and 'bbbb') in the top/main loop. The user event is handled by displaying the specified strings and incrementing a counter, respectively in the main and in the side loop. The main and side loop both contain a timer of 500 ms.


I expected both string indicators (main and side loop) to display 'aaaa' for 500 ms and then 'bbbb' 500 ms. Same for the numeric indicators, which show the counter. 1 for 500 ms, then 2 for 500 ms.


The indicators of the main loop work as I expected. The side loop however immediately shows 'bbbb' and 2. Given that the counter of the side loop shows 2, the first user event was registered in the side loop, but the timer of 500 ms was ignored?


Can somebody explain to me what is happening here? Id also be interested to know how to properly use the Unregister for event, Flush event queue and Destroy user event VIs to correctly release and clean up my user event.


Thanks in advance!

0 Kudos
Message 1 of 5

Not being able to look at your code currently, i'm guessing you only have 1 Register User Events?

If so, they'll have a common event queue so your event structure will take 1 event each.


G# - Award winning reference based OOP for LV, for free! ADDQ VIPM Now on GitHub
"Only dead fish swim downstream" - "My life for Kudos!" - "Dumb people repeat old mistakes - smart ones create new ones."
0 Kudos
Message 2 of 5

Thanks for your reply. I have two Register for events, one for each loop. From my little counter I can tell, that both loops receive both user events.


The top loop has basically the same user event case.

0 Kudos
Message 3 of 5
Accepted by topic author cadi

The 500 msec happens in parallel to the other things in the loop.


Let's look at both loops.


Wait functions in parallel to the event structure.

You hit OK and the OK Value Change event is queued. (By the time you do this, the 500 msec wait has probably already finished.)

Loop iterates and it executes OK Value change event.  Inside of that it is queues up user events A and B.  This will happen immediately, so the 500 msec wait still has to finish.

500 msec wait finishes.  Loop starts over.

Event structure will execute user event A immediately.  The 500 msec wait happens in parallel.  Once that wait is done, then loop starts again.

Event structure will execute user event B immediately.  The 500 msec wait happens in parallel.  Once that wait is done, then loop starts again.


You basically see a 500 msec wait between event A executing and event B executing.



Parallel Loop:

Wait happens in parallel and has probably already finished by the time the structure gets user event A

Event structure executes user event as soon as it receives it.  Loop iteration ends and starts over.

Event structure executes user event B since it is already queued up (almost immediately after user event A was queued up.

Wait on this iteration happens in parallel.


You basically see no wait between event A and event B executing.

Message 4 of 5

Thanks, thats it!

Added a third event 'cccc' and the results nicely align with your explanation.

0 Kudos
Message 5 of 5