11-05-2020 03:31 AM
Hello,
I'm trying to use the CVIXML functions for reading an xml file in a separated thread, created with CmtScheduleThreadPoolFunction() and not in the main thread.
Unfortunatley when I call the CVIXML functions, like CVIXMLGetNumChildElements, the thread stops and I must delete the application only from Windows Task Manager.
Does anyone know why?
I have read on the community that before start any call to the functions of the CVIXML library I must call the function
CA_InitActiveXThreadStyleForCurrentThread(NULL, COINIT_APARTMENTTHREADED) in the secondary thread created.
I tried but without success....
Does anyone help me please?
Best regards
E.
11-08-2020 05:44 PM - edited 11-08-2020 06:27 PM
You call CA_InitActiveXThreadStyleForCurrentThread() inside your thread callback routine before calling any XML function?
It may stil be not enough depending on other ActiveX technologies you call. Each ActiveX component can require its own threding configuration and some are simply not compatible with each other.
Apartement threading in itself means that the component is safe to be called from any thread but only the same thread ever. But that requires that that component is programmed and compiled as such and doesn't ever access resources that are not thread safe. Are you sure the XML component is that?
11-09-2020 02:28 AM
Hello Rolf,
thank you for your answer.
I confirm you that have call the CA_InitActiveXThreadStyleForCurrentThread() inside your thread callback routine before calling any XML function.
I'm sorry, but I don't understand what do you say in: "Apartement threading in itself means that the component is safe to be called from any thread but only the same thread ever". I'm confusing, is it safe to must be called from another thread or not, too? Or must be called only inside a thread?
Attache you can find the source code file with the the function called by the thread.
Waiting your answer
Best regards,
E.