Jump to content

Using the Timeout Event Case


crichter

Recommended Posts

I saw a clever and fairly simple piece of code this morning, where code to update a graph was written in the timeout case of an event structure. (It ran on LV7.0 and drats!!! I failed to save it). The timeout case was wired to timeout after 100 milliseconds.  My question is, would not code such as I just described, defeat the whole point of using an event structure, since the while loop outside the event structure was running most of the time?  Am I missing something?

Link to comment

What if you want to reset the graph when the user resizes the window? Or right clicks on a control? Or. Double presses the escape key? How would you handle this without the event structure? The code you described is very common using the timeout case. The only thing I would do different (but isn't needed) is to set the timeout to 1ms, then use elapsed time to only update every 100ms. Any event generated will reset that timer so if a user spams the keyboard where the event structure handles key down, the timeout may never happen. This functionality slightly changed in 2013. I haven't tried it but I heard the timeout isn't reset with dynamic events anymore.

  • Like 1
Link to comment

If you want to update the graph only after events come in, but don’t want the overhead of updating every event in a “burst”, you can put a “-1” constant inside the timeout case and wire it back through shift register into the timeout, and set the tunnel out to “Use default if unwired” so that the timeout is zero after any event other than timeout.

  • Like 1
Link to comment
Any event generated will reset that timer so if a user spams the keyboard where the event structure handles key down, the timeout may never happen. This functionality slightly changed in 2013. I haven't tried it but I heard the timeout isn't reset with dynamic events anymore.

Point of clarification: an event that is registered with an ES that DOES NOT have a case in the ES (unhandled), will not reset the timeout. In 2012, events that were registered but unhandled would reset the timeout.

Link to comment
Point of clarification: an event that is registered with an ES that DOES NOT have a case in the ES (unhandled), will not reset the timeout. In 2012, events that were registered but unhandled would reset the timeout.

Thank you for the clarification I knew there was some bug fix regarding how this was handled but I wasn't sure the specifics because I personally have that issue.

Link to comment
If you want to update the graph only after events come in, but don’t want the overhead of updating every event in a “burst”, you can put a “-1” constant inside the timeout case and wire it back through shift register into the timeout, and set the tunnel out to “Use default if unwired” so that the timeout is zero after any event other than timeout.

 

This is probably the most common pattern I use for making simple user interfaces. I think it's a great way of handling any interface whose rendering state can be determined from a single call. Things get more complicated for complex interfaces if you can't just go blindly rendering everything all the time, but most of the time I find this recommendation is spot on.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.