05-17-2007 06:10 PM - edited 05-17-2007 06:10 PM
Message Edited by Gabi1 on 05-17-2007 06:11 PM
Message Edited by Gabi1 on 05-17-2007 06:13 PM
05-17-2007 06:48 PM - edited 05-17-2007 06:48 PM
Message Edited by Jarrod S. on 05-17-2007 06:51 PM
05-17-2007 08:02 PM
I prefer to use the event structure to handle events and not have to do any type of configuring. I would suggest that you think about code architecture. I would suggest the producer consumer with events and a queued state-machine type. There is an example of this in the example finder.
That way the event structure handles your events or very small amount of code and the other loop handles the initialization or whatever type of code you want. This is a much more robust way of doing things.
05-17-2007 10:36 PM
05-17-2007 11:03 PM
05-17-2007 11:21 PM - edited 05-17-2007 11:21 PM
Message Edited by Jarrod S. on 05-17-2007 11:23 PM
05-18-2007 12:40 AM
producer-consumer loop!
very interresting. i am going to try it out.
but still i think about the data nodes of the event structure should be able to hold previously created data. i dont understand why it would be so bad architecturally.
i think this actually could be a point for improvement.
05-18-2007 09:15 AM - edited 05-18-2007 09:15 AM
Thanks for the backup jarrod,
Mike,
I agree with you also that sometimes it is overkill. If the code is small enough then stick it inside the event structure. The thing I like about queues and the event structure setup in a producer comsumer way is that I can have one producer (Event structure) and multiple consumers. Also I can have multiple producers and multiple consumers by using dynamic events all in one architecture without really having to change much to go from one to the other. This way the code is also more upgradeable and sometimes more robust.
Gabi1,
This may not be a bad idea but I think it would make the event structure a nightmare to debug (just my 2 cents).
Message Edited by Jhoskins on 05-18-2007 10:18 AM
01-07-2010 09:34 AM
Triggering events forces a thread swap to the user interface thread, which can slow down execution. It can also make a redundant copy of the data that has to get stored in the control whose value change was triggered, which you might not need. Enqueuing commands onto a queue does not have these limitations.
To clarify Jarrod's comment, it's important to note that neither the event structure itself nor dynamic events cause a switch to the User Interface Thread. Functions inside the event structure (e.g. property nodes, invoke nodes) can cause a switch to the UI Thread when they operate on UI components.
In that discussion, Jason King points out that:
"There is nothing specific about the event structure that requires the event-handling case to run in the UI thread. In fact, there is not any event that will force it to run in the UI thread"
"Reading from or writing to a front panel terminal or local variable does not cause the diagram to run in the UI thread."
"Any actual processing of user interaction, however - either looking at user interaction to determine which events to generate or finishing processing a filter event after the event structure has had a chance to discard it or modify any of the event details - requires the UI thread."
"Pretty much anything you do with the reference to a control or indicator will cause a switch to the UI thread (property nodes, invoke nodes, etc)"