LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

call library multiple times

I troubleshooting some issues and I was hoping someone might be able to give me some insight into what is going on.  I have some code in a suv-VI that looks like the following two snippets below.  In the "errors.png" configuration, the code runs for a number of minutes and the errors out with error 1097.  In the "runs.png" configuration, it seems to run just fine.  Does anyone know why this might be? 

 

My hunch is that the shared library I am calling into is not thread safe and that by using the error wire to establish a sequential dataflow relationship between the calls might avoid thread issues.

Download All
0 Kudos
Message 1 of 5
(2,519 Views)

That's certainly a possibility. You can change the reentrancy settings in the configuration for the Call Library Function Node - change it from "Run in any thread" to "Run in UI thread". The latter option forces all calls to that library function to execute sequentially. You'll need to set separately for each call library function node.

0 Kudos
Message 2 of 5
(2,489 Views)

I was actually going to mention that setting the calls to run in the UI thread eliminated the errors in the "errors.png" configuration (never see errors in the "runs.png" configuration).  The only downside to doing this was it appeared to cause odd behavior in my application at large (lock-ups).

0 Kudos
Message 3 of 5
(2,484 Views)

Seems pretty clear then that your hunch is correct and the DLL isn't designed to allow calls to multiple functions in parallel. You can sequence the calls yourself with the error wire or let LabVIEW do it for you by setting the Run in UI thread option. The former is more flexible (your code can run in some other thread) and the latter is safer (the calls will still be sequential regardless of how you structure your code).

0 Kudos
Message 4 of 5
(2,457 Views)

My hunch was correct.  I got word back from the DLL developer and he informed me that the code was most definitely not thread safe. 

0 Kudos
Message 5 of 5
(2,417 Views)