LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

stop dll execution

Dear all,I'm new to Labwindows/CVI and I'm not experienced with C...

My problem is very simple: I have to produce a system that calls functions contained into a DLL but I have to produce a mechanism to halt the execution of the called function.

In other word I call a DLL function and, if the user request it (for example if it takes too time), I have to terminate the execution of this function.

 

The real scope is:

 

LabVIEW calls a wrapper DLL.

The wrapper DLL calls (by name, contained into a string argument) a function contained into another DLL (defined by the user)

LabVIEW should terminate the execution of the previous step.

 

I have tried to stop directly the LabVIEW thread using the "abort VI", but I found that it doesn't work due LV is locked (or better the VI that calls a DLL function is locked) until the DLL function execution has been finished.

 

So I'm thinking to use threads in LabWindows/CVI to execute the DLL function (I will start one thread for each function) and the to use the CmtTerminateThreadPoolThread function of LabWindows/CVI to stop the execution of a thred.

 

I can't use the CmtExitThreadPoolThread function because my thread can't call the ProcessSystemEvents function because it will just call a DLL function, the thread code is similar to:

 

int CVICALLBACK executeExternalFunction(void* functionData) {

     externalFunctionArray[externalFunctionToExecuteArrayIndex]((char*) functionData);

}

 

Does the CmtTerminateThreadPoolThread function makes the thread to release all its resources (it will open GPIB handles)?

There is another way to stop a thread execution?

 

thanks

Andrea Costantino 

0 Kudos
Message 1 of 3
(3,074 Views)

How to move under LabWindows/CVI?

 

thanks 

0 Kudos
Message 2 of 3
(3,062 Views)

The easiest way this is solved is by some sort of global that your C code polls regularly to see if it should abort, and a function export that allows you to set that global from your calling process (eg. LabVIEW).

 

If you want to tie this into LabVIEW's abort system too, you could use the (falsely named) Call Library callback mechanisme that is availlable since LabVIEW8.2. In there you can configure functions in your DLL that LabVIEW should call before it executes a function (Reserve), after executing it (Unreserve), and when the hierarchy is aborted (Abort).

Message Edited by rolfk on 03-03-2010 02:53 PM
Rolf Kalbermatter
My Blog
0 Kudos
Message 3 of 3
(3,055 Views)