Showing results for 
Search instead for 
Did you mean: 
Reply

How to start and stop a timed loop from an event loop

Solved!
Go to Solution
Highlighted

How to start and stop a timed loop from an event loop

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!

 

labview_event_test.png

0 Kudos
Message 1 of 8 (946 Views)
Reply
0 Kudos

Re: How to start and stop a timed loop from an event loop

You have a data dependency and the outer loop cannot complete until everything in it has completed.

 


ishmael wrote:

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. Smiley Very Happy)

 

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?

0 Kudos
Message 2 of 8 (940 Views)
Reply
0 Kudos

Re: How to start and stop a timed loop from an event loop

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. 

 

regards

0 Kudos
Message 3 of 8 (937 Views)
Reply
0 Kudos

Re: How to start and stop a timed loop from an event loop

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.

0 Kudos
Message 4 of 8 (936 Views)
Reply
0 Kudos
Solution
Accepted by topic author ishmael
‎08-27-2015 06:09 PM

Re: How to start and stop a timed loop from an event loop

[ Edited ]

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.

 

 

Message 5 of 8 (922 Views)

Re: How to start and stop a timed loop from an event loop

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.

0 Kudos
Message 6 of 8 (913 Views)
Reply
0 Kudos

Re: How to start and stop a timed loop from an event loop

Can someone please downconvert the file to version 10.1?

 

Thank you in advance.

0 Kudos
Message 7 of 8 (641 Views)
Reply
0 Kudos

Re: How to start and stop a timed loop from an event loop


AnoAno wrote:

Can someone please downconvert the file to version 10.1?


Here you go....

0 Kudos
Message 8 of 8 (636 Views)
Reply
0 Kudos