Showing results for 
Search instead for 
Did you mean: 

Create a thread/ background execution

I want to create VI which is able to start a cyclical execution in background (e.g. send a message)
I run the VI and stop it, so the execution is not cyclical...but the event must run.

Thank you in advance
0 Kudos
Message 1 of 18

it is simple: just create a while loop. It will run in parallel to the rest of your vi. Inside the loop, perform the task that you want to be done regularly. Also, add a delay function from the time/dialog palette. In LabView 7.1 (which I don't have), there is also a special timed while loop which performs its timing on its own. You need to wire something to the stop terminal in the lower right corner of the loop, like a local variable, that can be set from outside the loop to stop it when needed.

0 Kudos
Message 2 of 18

Thank you for your responce!

Unfortunately the problem is not so easy to solve it. I want to stop the execution of the VI but the event must run into background ... so it cann't bbe solved into this manner. The way you said, when I stop the VI, also the VI stops ...
I want to create a sort of system event ...
0 Kudos
Message 3 of 18
I'm a little confused by what you want. You have your main application VI that you want to be able to stop, but still have the event running in the background? In otherwords you just want a background task that is always running? Does it actually have event code that runs in the main application VI?

You should take a look at the VI Server. For example the following code allows you to run a VI seperate from your application. When this code stops executing, the continues to run until it decides to stop.
0 Kudos
Message 4 of 18
Yes, you are right about the server behaviour ... want to
I am using also a server to lunch the VI which Istart ... but I can't lunch another VI until the previous doesn't execute ... logical 😞
So I should find another solution ... without consumer/producer manipulation because also the application from background should execute something cyclical ...
I think that I should triger a function from a dll and associate a timer with my event, then start the timer ... I belive that the timer doesn't stop until it is not called the explicit function ...
0 Kudos
Message 5 of 18
Could you explain a bit more about the application structure. The phrase "but I can't lunch another VI until the previous doesn't execute" through me for a loop - what are you saying there?

If you can describe the various parts and what the requirements are we can make more progress.
0 Kudos
Message 6 of 18
Yes, you are correctly with your assumptions ... but the application is quite complex and I've tried only to present my "problem" part ...

In principle is a kind of events problem ... when event appears the VI is treating it WHILE IS RUNNING. Of course it could be set to create a cyclical reaction. But what happen when I stop the VI ... NOTHING! So here is my problem ... I want to stop the execution but the event should be treat further.

I think deeper knowledges in VC and OS are required :))
0 Kudos
Message 7 of 18
If you need to be able to stop the VI and STILL have the events handles, then you need to seperate the event handler from the VI.

Then you have 2 background processes, not one.

I'm not 100% sure if seperating an event handler from code like this is easy, but you can't have a situation where code in a stopeed VI still executes. Seperating them is your only option.

Hope this helps

Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
0 Kudos
Message 8 of 18
Nope, it doesn't help me!

I am lunching the VI (or VI plus subVIs) from a server so the running time should be limited ? I think because otherwise I can't lunch the next VI to execute ...

Also I can start the execution manually but it wouldn't be automatically 🙂
0 Kudos
Message 9 of 18
It is possible to launch a VI within LAbVIEW without having to wait for it to finish executing. Look up the examples on VI server, there's bound to be a good example there.

Hope this helps

Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
Message 10 of 18