08-02-2019 05:39 AM
I used labview to generate a dll with a function related to my vi. The vi file includes an infinite loop which can be stopped manually in labview at the top-left (with that red "stop" button). But when I tried to use this function (exported to a dll and called by a C program), the function just stuck.
I did try to start this function at a different thread and kill that thread, but nothing works, the vi loop just keeps running.
I wonder if there is a certain way to stop it.
I called my dll using "lib" file, so I don't have to load (dynamically) the dll in my code.
The generated header file looks like this:
#include "extcode.h"
#ifdef __cplusplus
extern "C" {
#endif
/*!
* Kx_4_ZScanning
*/
void __cdecl Kx_4_ZScanning(LVBoolean start, int32_t Laser1, int32_t Laser2,
int32_t Laser3, int32_t Laser4, int32_t k, double IfScanning,
double DCOffsetX, double DCOffsetY, LStrHandle *physicalChannels1,
LStrHandle *physicalChannels2, double frequency, double z_num,
double delta_zX10nm);
MgErr __cdecl LVDLLStatus(char *errStr, int errStrLen, void *module);
void __cdecl SetExecuteVIsInPrivateExecutionSystem(Bool32 value);
#ifdef __cplusplus
} // extern "C"
#endif
08-02-2019 08:27 AM
Task manager will stop it (and LabVIEW).
You'd probably have to change the VI so it doesn't needs to be stopped with the abort button.
Make your own button, so the VI stops 'properly'. Also disable the abort button, so users can't click the abort button anymore.
08-02-2019 09:16 AM
You should not be using that red "Stop" (Abort) button (except in rare cases during development). That is a debugging tool. If you want to build an application that you can stop then you have to build in a proper stop, as wiebe@CARYA has already suggested.
08-02-2019 09:39 AM
1. modify your VI, so that the loop can be stopped by a global or a queue/notification, ...
2. export a new function to set the global, queue/notification when called.