Showing results for 
Search instead for 
Did you mean: 

How to stop a labview dll function call in C++?


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" {

* 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"


0 Kudos
Message 1 of 4

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.

0 Kudos
Message 2 of 4

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.

0 Kudos
Message 3 of 4

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.


0 Kudos
Message 4 of 4