12-08-2011 09:09 AM
Quick question about timed loops\event structures
Is it a good or a bad idea to use Event structures in timed loops - as opposed to while loops.? I guess I like the idea of timed loops - since you can set their priority - so if there is important stuff you need 100% priority in the background - but for ui you can set it to run slower\or run at a different priority level.
Just wanted to check there isn't a reason why i shouldn't be doing this - since all the examples don't do this.
JP
Solved! Go to Solution.
12-08-2011 09:42 AM
It wouldn't make sense to put an event structure in a timed loop unless the event structure had a timeout. That will cause a switch to the UI thread. You probably don't want any code in your timed loop to run in the UI thread.
12-08-2011 09:51 AM
I don't think this is a good idea. Your timed loop can stop completely waiting for an event. There is no benefit of placing the event structure in a timed loop. It is possible to assign priorities to other objects besides timed loops. For instance, you can assigned priorities to subVIs. I'm reasonably sure that the event structure can run at other priorities provided you are not doing any UI activities. Perhaps someone from NI can confirm this.
But the purpose of a timed loop is to have a deterministic periodic task. The event structure should be used for asynchronous events. The two are at odds with each other if they are in the same task.
12-08-2011 11:03 AM
@wideofthemark wrote:
Is it a good or a bad idea to use Event structures in timed loops
bad. +1
12-12-2011 05:27 AM
Thanks everyone for the advice. I guess I understand things better now - I think you are right that it doesn't make sense to have the two things together - although I have to say it doesn't really seem to have made a significant difference to how anything is running at the moment in my code.