From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to use Flush Event Queue Function with static events

Hi,

I would like to flush all unhandled events after my event structure loop is closed. In example: I have a VI with string control and boolean button. All these controls have its own event case for value change which closes the loop. If I type something in string control and update its value, not by pressing enter on my keyborad, but by clicking boolean button, I will have two events: one for string value change (which will close the loop) and second for button value change, which will not be handled. 

 

I solved this issue with dynamically registered events for these controls, but based on help for Flush Event Queue Function, I assume it is also possible to flush static events somehow... and this is my problem - how to do this?

 

Sorry I did not include my code, but I can't do this.

Michał Bieńkowski
CLA, CTA

Someone devote his time to help solve your problem? Appreciate it and give kudos. Problem solved? Accept as a solution so that others can find it faster in the future.
Make a contribution to the development of TestStand - vote on TestStand Idea Exchange.
0 Kudos
Message 1 of 14
(5,527 Views)

OK, I prepared some VIs which presents my problem. What is surprising for me is that if I enable dialogs in event structure then there is no unhandled button value change event (is it related with UI thread switching?). Anyway, you can see that if you disable dialogs in event structure, then the second VI call is closing just after it is open, because of unhandled  (in first VI call) button value change event. Unhandled button event can be seen in Event Inspector Window.

 

So how to flush this unhandled button static event with Flush Event Queue Function?

Michał Bieńkowski
CLA, CTA

Someone devote his time to help solve your problem? Appreciate it and give kudos. Problem solved? Accept as a solution so that others can find it faster in the future.
Make a contribution to the development of TestStand - vote on TestStand Idea Exchange.
Download All
0 Kudos
Message 2 of 14
(5,496 Views)

Sorry, I am not able to open your VI since I am still on 2012.  I'm also not familiar with the Flush Event VI since that was new in 2013.

 

But after looking around, there is a caveat associated with that function that you have to include it inside the event structure from which you want to flush the static events.  The wording from the online help file is this:

 


Note  If you wire include static events?, you must place this function inside the Event structure that handles the static events you want to include or omit from the flush operation.

Maybe this helps.

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 3 of 14
(5,470 Views)

Well I tried it this way but without any success 😞

Michał Bieńkowski
CLA, CTA

Someone devote his time to help solve your problem? Appreciate it and give kudos. Problem solved? Accept as a solution so that others can find it faster in the future.
Make a contribution to the development of TestStand - vote on TestStand Idea Exchange.
0 Kudos
Message 4 of 14
(5,460 Views)

Looking at the VIs you provided, I do not get any unexpected behavior. The subVI waits for the click on the OK button, no matter the state of the "use dialogs?" boolean value. As far as I am concerned, you have to explain or illustrate your problem better.

Marc Dubois
0 Kudos
Message 5 of 14
(5,414 Views)

Wire a True constant to the 'include static events?' input of 'Flush Event Queue' function.

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 6 of 14
(5,392 Views)

OK Marc I will try be more precise here.
When you run "MAIN UI Event Test.vi", with "use dialogs?" set to false, you will have "UI Event Test.vi" opened. Type something in a string control (do not press enter) and click ok button. "UI Event Test.vi" will be closed and the main application will be in loop 1. Then press "stop loop 1", and you will see that "UI Event Test.vi" will open and immediately close. Application will be in loop 2 now. When you then press "stop loop 2", you will see "UI Event Test.vi" again, and now it will work properly - will wait for your interaction.

 

 

My problem is with second "UI Event Test.vi". It is immediately closing because of unhandled "ok button" value change event. I thought that it is possible to use Flush Event Queue Function to clear unhandled event, but without registering dynamic events for string and bool controls.

 

Michał Bieńkowski
CLA, CTA

Someone devote his time to help solve your problem? Appreciate it and give kudos. Problem solved? Accept as a solution so that others can find it faster in the future.
Make a contribution to the development of TestStand - vote on TestStand Idea Exchange.
0 Kudos
Message 7 of 14
(5,387 Views)

@Paul

I tried it. I placed Flush Event Queue Function inside event structure with "include static events?" set to true, but it's is not working as I want.

Michał Bieńkowski
CLA, CTA

Someone devote his time to help solve your problem? Appreciate it and give kudos. Problem solved? Accept as a solution so that others can find it faster in the future.
Make a contribution to the development of TestStand - vote on TestStand Idea Exchange.
0 Kudos
Message 8 of 14
(5,386 Views)

You're right, it does seem to be a bit buggy.  I tried a few different things, but couldn't get it to work properly.

You may have to resort to User Events to do what you want.

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 9 of 14
(5,382 Views)

When configuring an event, in the "Edit Events" dialog, there is an option that is selected by default: "Lock panel (defer processing of user actions) until the event case completes".

Lockpanel.png

When this option is selected, only one event is processed at a time. If you flush the events in the "String value change" event, the "Ok button" event is not available to flush yet.

If you uncheck that option in the event config, you should see the expected behavior... except that in my case, I had to add a 100 to 200 ms delay before flushing the events for the "Ok button" event to disappear. If you use Execution Highlight or set a breakpoint, it works as well.

delay_flush.png

Marc Dubois
Message 10 of 14
(5,366 Views)