LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to Implement a Background Worker in a Start/Stop Sub VI

Solved!
Go to solution

Hello, I have some Problems with understanding Parallel Processing in LabVIEW.

I have a working VI that processes some Events coming from a .dll (Windows File Change events)

PaulPascher_0-1652433585184.png

In a Next step, I wanted this VI to run parallel to other LV Code. To accomplish this, I mapped a stop button reference out.

This worked fine, as long as the Button reference was in an Open Vi.

 

But I wanted to pack it behind a Start/Stop Sub VI callable from anywhere. To accomplish this, I changed the button reference to a User event I registered with Create User event and Generate User Event.

PaulPascher_1-1652433708688.png             PaulPascher_2-1652433793680.png

 

The now new Problem I ran into was that my Start/Stop SubVI can’t be run with Stop since its Start Call never ends.

I’m not sure whether I explained it understandable, I hope my Attached Pictures Help.

 

Basically, I have a Logic-Task which I want to pack in some sort of Background worker VI which can be started and stopped from anywhere without any other regards.

I Think I miss some Fundamentals, since such a thing should be easy to implement in any programming environment.

 

I’m Thankful for any Advice, Tutorial recommendation or “bash word” to lookup!

 

0 Kudos
Message 1 of 7
(239 Views)

It is not really helpful to attach some random code pictures. We have no idea what we are looking at.  Not sure what a stop button reference (not seen anywhere) has to do with "parallel processing".

 

Maybe if you would attach a simplified version of your VIs we would get a better "picture" of your problem. 😄

0 Kudos
Message 2 of 7
(225 Views)

The second I saw Background Worker from .NET world, I blinked.

 

I am not understanding what is the Background Worker suppose to be doing?

And what is the main loop suppose to be doing?

0 Kudos
Message 3 of 7
(223 Views)
Solution
Accepted by topic author PaulPascher

@PaulPascher wrote:

Hello, I have some Problems with understanding Parallel Processing in LabVIEW.

I have a working VI that processes some Events coming from a .dll (Windows File Change events)

PaulPascher_0-1652433585184.png

In a Next step, I wanted this VI to run parallel to other LV Code. To accomplish this, I mapped a stop button reference out.

This worked fine, as long as the Button reference was in an Open Vi.

 

But I wanted to pack it behind a Start/Stop Sub VI callable from anywhere. To accomplish this, I changed the button reference to a User event I registered with Create User event and Generate User Event.

PaulPascher_1-1652433708688.png             PaulPascher_2-1652433793680.png

 

The now new Problem I ran into was that my Start/Stop SubVI can’t be run with Stop since its Start Call never ends.

I’m not sure whether I explained it understandable, I hope my Attached Pictures Help.

 

Basically, I have a Logic-Task which I want to pack in some sort of Background worker VI which can be started and stopped from anywhere without any other regards.

I Think I miss some Fundamentals, since such a thing should be easy to implement in any programming environment.

 

I’m Thankful for any Advice, Tutorial recommendation or “bash word” to lookup!

 


Guessing here since only have pictures. But here it goes,

Your start call never ends because of data flow. You start the VI, and it waits until its error out node completes before moving to the next stage. What you want to change is how you start the VI. You call use an Asynchronous Call and Forget Node to start the VI, that way it will run in the background. The example finder has good examples of the Call and Forget functionality. Below is picture to show you an example.

 

Snap8.png

Message 4 of 7
(211 Views)

I addend a minimal Example for Clarification.

 

SomeCode.vi should run in parallel to Main.vi without any regards on how I call it from Main.vi I only want to start and stop it anywhere anytime with the help of the Background Worker.vi. I do not want to cahnge anything in my Main.vi

 

Basicly some Easy to Use sort of task.start() or task.stop() from other Programming Languages. 

 

@mcduff

This looks promising, Thank You! I will check it out and respond again after.

Download All
0 Kudos
Message 5 of 7
(196 Views)

Have to go to meeting now, but Start Async Call is what you want to use. Start the VI in the background and then go to the next step. I do this all the time and use User Events to send messages to the VIs. The biggest thing you need to do, is make sure your background tasks stop when you tell them to stop. That can be an issue. Otherwise when you have a VI inline dataflow is what controls execution.

0 Kudos
Message 6 of 7
(192 Views)

Haven't seen this part of LabView yet.

Tested it and it worked perfectly!

 

For Completion of this question, I added the now in parallel working example VI's.

 

Thank you for your help!

Download All
Message 7 of 7
(143 Views)