ILogListener to catch Convert to PDFA errors in multiple threads  SOLVED

PDF-XChange Editor SDK for Developers

Moderators: TrackerSupp-Daniel, Tracker Support, Paul - Tracker Supp, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, 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
zarkogajic
User
Posts: 1370
Joined: Thu Sep 05, 2019 12:35 pm

ILogListener to catch Convert to PDFA errors in multiple threads

Post by zarkogajic »

Hi Support,

This is an extension question to the one in this topic: https://forum.pdf-xchange.com/viewtopic.php?p=160002#p160002

In short: I'm converting Core documents to PDFA in multiple threads.

I do not want the default report to be displayed, so setting "ShowReport = false" for GetFormatConverterParams used with Convert method.

This works fine and if Convert results in E_FAIL, the registered ILogListener will call OnLogMsg with LogMsg_Error and the text of the error.

However, as said in the Subject - I'm converting to PDFA in multiple threads - each thread works on a single Core document. If in each thread I would register a new listener, due to the nature of multithreading when Convert fails and OnLogMsg is called - it gets called multiple times - and I do not see a way to differentiate between those OnLogMsg calls.

If I register only 1 ILogListener during the conversion (so 1 for all files / threads) - I do not see a way to know which file failed using OnLogMsg. The pMsg (ILogMsg) does not provide additional data to figure this out.

Is there a way to get Convert errors in any other way than using ILogListener? Like: can ICab (GetFormatConverterParams) be read *after* failed conversion to get the errors?

p.s.
What is "ErrorMessage" in GetFormatConverterParams for 'conv.exp.pdfa'



-žarko
User avatar
Vasyl-Tracker Dev Team
Site Admin
Posts: 2352
Joined: Thu Jun 30, 2005 4:11 pm
Location: Canada

Re: ILogListener to catch Convert to PDFA errors in multiple threads

Post by Vasyl-Tracker Dev Team »

Hi Zarko.

The working solution for this problem (pseudocode):

Code: Select all

converThreadFunc(doc2pdfa)
{
    threadID = GetCurThreadID();
    
    thread2DocNameMap.ThreadSafe_Add({ threadID, doc2pdfa.SrcInfo.FileName });
    doc2pdfaConverter.Convert(... doc2pdfa ...);
}

OnLogMsg(...) 
{
    threadID = GetCurThreadID(); // the doc2pdfaConverter.Convert calls the OnLogMsg in the same thread...

    IAFS_Name name = thread2DocNameMap.ThreadSafe_GetName(threadID); 
    if (name) 
    {
          ....
    }
}

HTH.
Vasyl Yaremyn
Tracker Software Products
Project Developer

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
zarkogajic
User
Posts: 1370
Joined: Thu Sep 05, 2019 12:35 pm

Re: ILogListener to catch Convert to PDFA errors in multiple threads  SOLVED

Post by zarkogajic »

Hi Vasyl,

Thanks, GetCurrentThreadId did the trick.

-žarko
Post Reply