Page 1 of 1

Loading and freeing core.dll and pxc_inst successively in different threads

Posted: Wed Feb 27, 2019 2:06 pm
by Kutusow
Hey,

I am working on a Wrapper of your IPXC_Document class.
When the first document is created in my program, I load the Core dll and instantiate the IPXC_INST in an abstract Manager class.
Afterwards I keep track of the number of documents that are reachable. When this count becomes zero, I finalize the IPXC_INST and call FreeLibrary on the dll. So far so good.
Now, I have discovered some curious behaviour. When i create my first document in a Task (main thread is STA), do some work on it and dispose of it afterwards, the IPXC_INST is finalized and the dll is freed as desired (still in the same thread).
But if I proceed by creating a new instance of my document class in the main thread, the new IPXC_INSTANCE throws the following Exception, when I try to call methods on it:
0x80004002 (E_NOINTERFACE) (no such interface supported)

this does not happen, if I create and dispose documents in the main thread only (no matter how often I reload the library).
Do you have any idea, why this is?

best regards,
Kutusow

Re: Loading and freeing core.dll and pxc_inst successively in different threads

Posted: Wed Feb 27, 2019 2:59 pm
by Sasha - Tracker Dev Team
Hello Kutusow,

Here's a link to a topic that can prove useful:
viewtopic.php?f=67&t=31761

Cheers,
Alex

Re: Loading and freeing core.dll and pxc_inst successively in different threads

Posted: Thu Feb 28, 2019 11:24 am
by Kutusow
Hey,

thank you for the link. I already read it before and it doesn't really help me.
When I create the pxc_inst in say thread A and then try to access the initialized instance in thread B via the static property of my manager class, the instance throws exceptions. It works, if my main thread is MTA, but unfortunately I have to use STA for other reasons.

I just want to make sure, that loading the library in thread A, initializing the pxc_inst, working with it and then finalizing it and freeing the library, does not keep me from later on doing the same thing in a different thread.

Do you have any idea, why this does not work?

Re: Loading and freeing core.dll and pxc_inst successively in different threads

Posted: Tue Mar 05, 2019 9:52 am
by Sasha - Tracker Dev Team
Hello Kutusow,

If you are not writing in C++, then I'm afraid that you should only use MTA for the correct behavior.
What you can do is launch the separate MTA thread where the IPXC_Inst would be initialized and then launch all of the other threads from this MTA thread. And of course, after all of the work done, finalize the instance in this MTA thread and then kill the thread itself.

Cheers,
Alex