Perform library exit
Vision Point API allocates specific resources during operation, which must be released before the library is unloaded from the process.
Memory buffers
When you use 'KYFG_StreamCreateAndAlloc()', and memory buffers are allocated by our library, they are marked as such (to distinguish with a scenario when buffers were allocated by the user program, announced using 'KYFG_BufferAnnounce()' and thus should also be released by the user program). These buffers are released by KAYA Instruments library when the user calls 'KYFG_StreamDelete()', which should be done by the user's application.
If you do not call 'KYFG_StreamDelete()', it will be internally called by the 'KYFG_CameraClose()', which also should be done by the user's application. If, for some reason, you also do not call 'KYFG_CameraClose()', it will be internally called by the 'KYFG_Close()', which your application must call at some point.
Background monitoring thread
There is a background monitoring thread started by our library when an application calls 'KYFG_Open()' \ 'KYFG_OpenEx()'. This thread is stopped when 'KYFG_Close()' is called. Unloading the library without closing all grabber handles may lead to undefined behaviour (uncaught exceptions, etc.). You application must call 'KYFG_Close()' before unloading the library.
Callback thread
This thread is activated by DMA interrupts and triggers the application's stream callback functions. As this process is asynchronous, there's no assurance that the application's stream callback won't be invoked after other '.Close()' calls have been made. Your application should ensure that any stream callback invocations are disregarded once it has closed all previously mentioned handles.
NOTE about DLL_PROCESS_DETACH in Windows
One could expect that when our DLL is unloaded from the process memory, it can automatically release all relevant resources (stop threads, unpin and release memory, etc). Unfortunately, as it is stated in the "DllMain entry point" documentation, "There are significant limits on what you can safely do in a DLL entry point". Our library does implement some cleanup steps in its DllMain function, but it is still responsibility of an application to perform full cleanup before library is unloaded.
Please remember that it's essential to halt the stream before closing.