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: 

using event twice in diffefent pleces

Is it possible to have two event structures waiting for the same event?
in my program there is one while loop which handles all the events (like the stop button etc.)
In another place, the program has to wait for the stop button or a 'step' button or a user defined time (timeout).
Currently, the main event structure writes True to step/ stop when they are pressed. I've tried using an event structure in this place too, but then the events que up, which i dont want to happen. Is there a way to use an event structure here, or is it fine this way?
wait for stop or step.png
Ragnar
0 Kudos
Message 1 of 5
(2,254 Views)

Yes.  Two event structures can wait for the same event.

 

Without seeing your actual code, I don't know why you are having problems now with events queuing up.  Seeing the global variables in the bit of code you did post scares me a bit.

 

 

0 Kudos
Message 2 of 5
(2,251 Views)

If I understand correctly the OP wants Dynamic events.

Dynamic events can be "registered" and "Unregistered" by any event loop (Or multiple event loops)  the dynamic events will not enqueue into the event structure's "event queue" unless the event structure is registered for that event at the time the event occurs.  So if "Stop" and "Step" were dynamic events (generated by a user key-press) you could press the button all day until the event was registered and fire the case after the next time the key was pressed. 


"Should be" isn't "Is" -Jay
0 Kudos
Message 3 of 5
(2,241 Views)

me too:P

The globals are also used in some sub-vi's, but i am now trying to replace them by better ways of data transferring.

 

The problem is that the code I posted is running only ocasionally, and the user could press the stop button a lot of times before the code executes first. (The stop button only 'restarts' part of the program in a while loop, I should have made that clear)

If in that case the code executes for the first time, it still has a queued stop button value change, so it continues immediately.

0 Kudos
Message 4 of 5
(2,240 Views)

It sounds like you have some more fundamental problems in your code then simply trying to catch the event in two event structures. You should try to separate the UI processing from your actual processing tasks. From what you describe it sounds like your process and UI handling are mixed together. This results in unresponsive user interfaces which can lead to the problem you are seeing. The UI processing should be lean and mean. This way it is very responsive to the user. You may not be able to act immediately on their request but you can provide feedback that you received their request and are working on it. How quickly you can inject their request into your processing code will depend on how that is actually implemented.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 5 of 5
(2,230 Views)