LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem using CVIXML library in a separate thread

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.

0 Kudos
Message 1 of 3
(1,199 Views)

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?

Rolf Kalbermatter
My Blog
0 Kudos
Message 2 of 3
(1,147 Views)

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.

0 Kudos
Message 3 of 3
(1,134 Views)