C1FlexReport RenderToFilterAsync "Operation is not valid"

Posted by: andy.curry on 30 April 2024, 7:08 pm EST

    • Post Options:
    • Link

    Posted 30 April 2024, 7:08 pm EST

    We have a system which generates three PDF files sequentially based on an INT parameter and a FlexReport template. I found through testing that it takes around eight seconds for the files to be generated and wanted to speed this up using tasks as the files are not interdependant.

    After creating the tasks and testing I found an issue using RenderToFilter within a task as it would throw an error that the index could not contain the same key.

    I found the RenderToFilterAsync method along with the Ex version, both of which get past the above error but then throw “System.InvalidOperationException: ‘Operation is not valid due to the current state of the object.’” The first task executes but then stalls when the second tries to complete.

    This exception was originally thrown at this call stack:

    C1.Win.C1Document.C1DocumentSource.a(C1.Win.C1Document.Export.ExportFilter)

    C1.Win.C1Document.C1DocumentSource.ExportAsyncEx(C1.Win.C1Document.Export.ExportFilter)

  • Posted 1 May 2024, 7:50 pm EST

    Hello,

    We were able to replicate this behavior if we used the same FlexReport object among multiple threads running simultaneously. This happens because FlexReport object is locked (currently generating), and in-between, another thread tries to access and generate it again.

    You can avoid this error by creating a separate FlexReport object for each thread and then trying to generate PDFs. Please refer to the attached sample for implementation. (see FlexReport_RenderToFilterAsync.zip)

    If our implementation differs from yours, please update the sample attached or attach a stripped-down sample so that we can observe and investigate the behavior on our end.

    Regards,

    Uttkarsh.

  • Posted 1 May 2024, 9:18 pm EST

    Hello Uttkarsh,

    Thank you for the explanation and sample - I reworked my code based on this and am pleased to advise that it has resolved the problem. Thank you so much!

    Kind regards,

    Andy

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels