3.2   Terminate HALCON Library

In applications where DLLs are unloaded in a thread-exclusive context, e.g., with FreeLibrary() under Windows, the HALCON library will not terminate properly if there are still active HALCON threads.

A possible scenario where the problem may occur is, e.g., when using HALCON/C++ to implement an ATL control.

To overcome this problem, it is necessary to call the function FinalizeHALCONLibrary() before unloading the DLL. Please note that the application has to be linked against halcon.lib. Make sure that the call to FinalizeHALCONLibrary() is not from within any other DLL's DllMain function. Please note that once FinalizeHALCONLibrary() has been called, no further HALCON functions may be called. Please also note that the HALCON library is not capable to free all resources properly during termination. This might result in memory leaks when loading and unloading the HALCON library repeatedly.