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.
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.
03-14-2017 02:52 PM
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.
03-14-2017 04:18 PM
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?
03-14-2017 04:53 PM
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.
03-14-2017 05:41 PM
Well I tried it this way but without any success 😞
03-15-2017 08:31 AM
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.
03-15-2017 02:05 PM
Wire a True constant to the 'include static events?' input of 'Flush Event Queue' function.
03-15-2017 02:19 PM
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.
03-15-2017 02:23 PM
@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.
03-15-2017 02:45 PM
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.
03-15-2017 07:46 PM
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".
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.