05-13-2012 10:27 AM
I would like to have a timed loop and an event loop running simultaneously. Is there a simple, clean way of doing this? (i.e. without hideous queues, etc.) My attempt is shown below. Unfortunately, as soon as the timed loop starts, the event loop becomes unresponsive. Thanks for your help!
Solved! Go to Solution.
05-13-2012 11:43 AM
You have a data dependency and the outer loop cannot complete until everything in it has completed.
I would like to have a timed loop and an event loop running simultaneously. Is there a simple, clean way of doing this? (i.e. without hideous queues, etc.)
You could use a regular queue. I would recommend against hideous queues, even though I don't quite know hat that would be. )
In order for the event structure to be ready at all times, it needs to be in its own loop.
(Nobody likes to write examples from scratch, so please attach your code so someody here can maybe try to modify it).
Also please be more specific about the purpose of your code. What is is actually supposed to do?
05-13-2012 11:47 AM
Try put the button start/stop inside the while loop and replace signal of button with NewVal, the event case will work and the control refresh your status when run.
05-13-2012 11:49 AM
Thanks for the reply, altenbach. I've attached my VI - sorry about that. All I'd like my code to do is allow for a timed loop to be started or stopped with the click of a button. In my sample code, when the timed loop is running, it should just display an increasing loop count.
05-13-2012 12:22 PM - edited 05-13-2012 12:37 PM
You don't need the outer loop. Place the event structure inside the timed loop and manipulate the timeout between zero and infinite, depending on the desired state.
05-13-2012 12:35 PM
That's great, thanks! It works perfectly, although intuitively, I would have thought that the event loop would not run until after the timed loop was already running. In any case, this is elegant and simple. Thank you.