Showing results for 
Search instead for 
Did you mean: 

How can I run two diffrent "tasks" at the same time?

Go to solution


I made a project in LabView for my university project, but I don't have much experience in using LabView.
I have a problem with the project when I try to run two diffrent things at the same time, for exemple, if the "Temperature" is set to a value that activates the LED, then I can't use the button to activate the alarm system and so on, I would like to be able to use them all al the same time.

Download All
0 Kudos
Message 1 of 6
Accepted by topic author StephenXIV

Most of your "code islands" are not even inside a loop, so they will execute exactly once at the start of the program, then never again!


I recommend to start with the basic tutorials first.


All you probably need is one toplevel while loop and a clean state machine architecture.

Message 2 of 6
Accepted by topic author StephenXIV

You will find that you can indeed use both at the same time. Switch the alarm to on prior to running the VI, make sure your temperature it out of range, then observe that you can trigger the temperature LED exactly once while the alarm is functioning. After this point the temperature loop has terminated. It will not work again.


You cannot set the alarm after starting the VI with it off because the loop in which you read that control ends after just one False read. Likewise, you cannot trigger the LED more than once because the loop ends as soon as the temperature is in range.


I suspect that you believe that only one works at the same time because you are using the Run Continuously button. That button is a trap for newbies. You should very rarely use that and only for debugging purposes. It will not restart your application until the entire VI completes, so if you have the alarm on then its loop does not end and the temperature loop never restarts... but restarting the temperature loop is not the way to keep the monitoring working. (A different subject, but you should also not rely on the abort button to stop your program. That's basically the equivalent to killing it from the task manager; only to be done if it has stopped working properly.)


If you structure your code into parallel loops like this then you need those loops to stay alive throughout the lifetime of your program and some way of communicating between loops to stop them. See attached for a rudimentary example that triggers a notification when the panel user clicks the Close button. (Also watch out for greedy loops. You have nothing constraining the speed of your temperature monitoring loop and it consumes a ton of CPU cycles while active.)


Otherwise, you need to structure all of your functionality into a single top level loop. That's certainly possible, but would take a bit longer to do properly, so I leave that to you if you wish to pursue it.

Message 3 of 6

Yes, I was indeed using the Run Continuously button and I wanna thank you for the information regarding his functionality and also for the abort button, with I do indeed use as well. I was not aware of the negative sides of using it.

The information that you provided me helped me understand better what I have to do, thank you for your time and I hope you have a greate day.

0 Kudos
Message 4 of 6

Thank you for the advice, I think you are right in these regard, I will read a little bit more about the besics until I will try to go further. And yes, I knew about the fact that my project executes just at the start of the running sequence, but I was using the Run Continuously button because I did not understand his use corecttly at the time, so I did not noticed at first that that will probably be a problem! o.O

Thank you for the advice again and I hope you have a wonderful day!

0 Kudos
Message 5 of 6

Thank you for the advice, I will read some more before trying to go further.

Yes, I'm was aware that my project will work just once when I press the Run button, but I did not realised that this was a problem, because I was using the Run Continuously button insteed (I did not understand his functionality correctly at the time).

Also, yes, the solution was to use a toplevel while loop. 

Thank you again for the support and I hope you have a wanderful day!

Message 6 of 6