Jump to content

Calling a DLL in parallel


Recommended Posts

Hello everyone,

I have a program wich makes dynamic calls to driver VIs that we put on the driver folder. What it does is list the folders of the folder, and create an array of paths, wich we feed to a for loop that opens a VI reference and runs them, one by one, with the Invoke Node Run VI.

We have some drivers that run just once (no loop), and others that must run in parallel (looping), and it all works fine because we can set Wait Until Done to false when calling the looping drivers.

My problem is that now we decided to create DLLs out of the drivers, and when using the function Call Library Function, there`s no way to call a looping dll and continue the execution of my main program as I did before when calling the VI`s. The CLF waits until the dll finishes executing and just after that the main program can continue executing.

Creating a loop for each DLL call is not an option since our program has to be able to adapt itself for different numbers and types of drivers without us needing to code.

One alternative I was thinking was calling a VI that would call the looping dll. That would work, but wouldn`t be pretty.

Does anyone have any suggestion for my problem?

Thank you very much,

Dario Camargo

Link to comment

QUOTE (esqueci @ May 4 2009, 09:15 AM)

Hello everyone,

I have a program wich makes dynamic calls to driver VIs that we put on the driver folder. What it does is list the folders of the folder, and create an array of paths, wich we feed to a for loop that opens a VI reference and runs them, one by one, with the Invoke Node Run VI.

We have some drivers that run just once (no loop), and others that must run in parallel (looping), and it all works fine because we can set Wait Until Done to false when calling the looping drivers.

My problem is that now we decided to create DLLs out of the drivers, and when using the function Call Library Function, there`s no way to call a looping dll and continue the execution of my main program as I did before when calling the VI`s. The CLF waits until the dll finishes executing and just after that the main program can continue executing.

Creating a loop for each DLL call is not an option since our program has to be able to adapt itself for different numbers and types of drivers without us needing to code.

One alternative I was thinking was calling a VI that would call the looping dll. That would work, but wouldn`t be pretty.

Does anyone have any suggestion for my problem?

Thank you very much,

Dario Camargo

You are correct as far as I know - you'll need to dynamically call the wrapper VI that calls your DLL in order to launch a new thread for that VI to keep your DLL call from blocking. With that said, it seems like you're building LabVIEW code into a DLL and then calling it from LabVIEW - seems like the hard way to do things. I would also think that you could call the DLL in a loop - if the DLL has enough info to know how many times to loop, it seems like you could make a call to a DLL method and get that info - like how many times to iterate thru a for loop. If the call in the DLL is in a while loop, just return whatever exit condition you use to terminate the while loop from the DLL call and use that to terminate your loop around the DLL call.

Mark

Link to comment

QUOTE (esqueci @ May 4 2009, 11:15 AM)

My problem is that now we decided to create DLLs out of the drivers, and when using the function Call Library Function, there`s no way to call a looping dll and continue the execution of my main program as I did before when calling the VI`s. The CLF waits until the dll finishes executing and just after that the main program can continue executing.

I've used two ways to solve this issue...

The first is to call a function in the DLL that programmaticaly executes another VI inside the DLL. This can be fairly self-contained and you can use function calls to interact with the parallel loop (including terminating it). A static reference to the looping VI works pretty well.

The second is to use VI server to obtain a reference to a VI inside a DLL. This can be messier and I would recommend avoiding it as you start dealing with different memory spaces.

Tim

Link to comment

Hello everyone and thanks for all of your help.

I`ve tried the method Mesmith suggested and it still wouldn`t allow the execution to proceed with the dll looping. I have no idea why LabVIEW works like this, I tought it would create another thread and run in parallel but it does not.

The first method of Tim_S worked for me. I created a DLL VI that opens a reference to the looping vi, changes some controls values, and executes it. When building the DLL I put the DLL VI as Exported VIs and the looping VI as always included.

Thanks again for everyone`s help.

Dario Camargo

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.