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

A forum for questions or concerns related to the PDF-XChange Core API SDK

Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Sean - Tracker, Chris - Tracker Supp, Tracker Supp-Stefan

Forum rules
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.

When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
Post Reply
Kutusow
User
Posts: 18
Joined: Tue Oct 30, 2018 12:14 pm

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

Post by Kutusow » Wed Feb 27, 2019 2:06 pm

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

User avatar
Sasha - Tracker Dev Team
User
Posts: 4419
Joined: Fri Nov 21, 2014 8:27 am
Contact:

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

Post by Sasha - Tracker Dev Team » Wed Feb 27, 2019 2:59 pm

Hello Kutusow,

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

Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

Kutusow
User
Posts: 18
Joined: Tue Oct 30, 2018 12:14 pm

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

Post by Kutusow » Thu Feb 28, 2019 11:24 am

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?

User avatar
Sasha - Tracker Dev Team
User
Posts: 4419
Joined: Fri Nov 21, 2014 8:27 am
Contact:

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

Post by Sasha - Tracker Dev Team » Tue Mar 05, 2019 9:52 am

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
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

Post Reply