12-05-2011 02:46 PM
Hello,
I have severals application where I have an event structure managing user event (buttons). When I push a button, the event case associate to this button will execute. My problem, is that while this event is executing, I want to be able to continue to be able to let say, change a tab in the tab control so I cannot use the "lock front pannel" button.
What I would like to do is to be able to clear the user event queue so if someone push a certain button while in the event case, it won't execute when the event case will be done.
Is it possible?
Thank you,
Simon-Pierre
Solved! Go to Solution.
12-05-2011 02:59 PM
Sounds like you want a filter event, they are included in "Edit Events" and end in question mark, red colored. Btw, If you do NOT set the boolean in the filter event to cancel or NOT you could wind up with a "frozen" FP. Check examples for how to use it.
From the user Help "Filter events inform you that the user has performed an action before LabVIEW processes it, which allows you to customize how the program responds to interactions with the user interface. Use filter events to participate in the handling of the event, possibly overriding the default behavior for the event."
12-05-2011 03:00 PM
If you are doing the processing within the event structur eyou will not be able to service events any faster or more frequently than the time it takes to complete the processing. If you want the UI to be very responsive you will probably have to use the producer/consumer architecture. This allow the event structure to run quickly and it passes the actual processing to a parallel task. You may also have multiple parallel tasks if necessary.
12-05-2011 03:08 PM
"My problem, is that while this event is executing, I want to be able to continue to be able to let say, change a tab in the tab control so I cannot use the "lock front pannel" button"
.
But after a second read of your post, I have changed my response to use the notify events (uncheck "Lock FP till event completes...) for continuous operation of UI. That is it. It sounds like this is what your doing, just uncheck Lock FP.
12-05-2011 04:13 PM - edited 12-05-2011 04:16 PM
@richjoh wrote:
"My problem, is that while this event is executing, I want to be able to continue to be able to let say, change a tab in the tab control so I cannot use the "lock front pannel" button"
.
But after a second read of your post, I have changed my response to use the notify events (uncheck "Lock FP till event completes...) for continuous operation of UI. That is it. It sounds like this is what your doing, just uncheck Lock FP.
This will not address the issue that the OP wanted to process other events in parallel. Unless you have parallel tasks like in the producer/consumer architecture you can only process one event at a time. It is impossible to rocess them in parallel using a single loop with an event structure.
And after further rereading the OP the only way to accomplish not getting events for certain buttons/controls while servicing a particular event would be to disable the controls to prevent the events from getting queued. If the control is enabled you will get an event for every time the button is pressed.
12-05-2011 04:28 PM
Lets hear if coolaid whats to do parallel processing that I believe Mark mentioned. No event structure will do that correct. Albeit, coolaid is using one anyhow, well Consumer Producer would require a rework of his code (easily done of course) but why throw away work already done. Consumer producer has its place, it not for every problem of a slow UI.
By unchecking "lock FP till event completes" when that will free up FP processing like clicking on a control. Is that Parallel processing, well maybe and maybe not, coolaid has not posted his code.
12-05-2011 04:42 PM
@richjoh wrote:
Lets hear if coolaid whats to do parallel processing that I believe Mark mentioned. No event structure will do that correct. Albeit, coolaid is using one anyhow, well Consumer Producer would require a rework of his code (easily done of course) but why throw away work already done. Consumer producer has its place, it not for every problem of a slow UI.
By unchecking "lock FP till event completes" when that will free up FP processing like clicking on a control. Is that Parallel processing, well maybe and maybe not, coolaid has not posted his code.
You would not be able to process other items if the code all resided inside the event structure. In a single loop with an event structure you can only porcess one event at a time. Any lengthy processing in that event structure will mean that you have an unresponsive UI. You cannot process the next event until the current event completes. If that event takes 30 seconds, your UI is effectively unresponsive for 30 seconds. If they simply want to change a value in a control while the other processing is being performed they can. However, depending on how the code is written it may not see that change right away. If the control is read outside of the event structure the value you read could be quite old (assuming there is no event for that control.)
Regardless, some code would be helpful to see what they have and what they truly desire.
12-05-2011 11:55 PM
In the original post, there is no mention of long processing time of event structure. If that was the case, still uncheck the "Lock FP till event completes..." that will prevent the "freeze" unresponsiveness of the event structure compared to when the feature is enabled.
As I read the question more and more its a contradiction. "I cannot use lock FP", "while in the event case" then negates it with "I want to clear it" (so its not cleared, hugh). But an event structure should NOT be code for long processing times, the FP will freeze. Unchecking "lock FP till event completes" is a way around this. You see the inherent Labview queues your keyboard and mouse events (no Produce Consumer needed). Simone-Pierre, I think you want help on using the event structure while not crashing your UI.
Yes, Consumer Producer is just a loop (action and event) that cues the FP UI controls. My suggestion is an easier fix.
12-06-2011 07:46 AM
Thank you for your answer, my problem is really that I need to cancel all the events that occured meanwhile I was processing the first event. Of what I see, the producer/consumer method would do the same. But I will try to incorporate it as it would be a better management.
So right now, my only option would be to disable the button at the beginning of the event and to re-enable it at the end?
Thank you,
Simon-Pierre
12-06-2011 08:09 AM
For the record, Producer consumer doesn't cancel any event. Producer consumer queues events. Do you really want to cancel all events after 1 event fires? Or is it process one event at a time while never slowing down your UI.