Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

TppTemplate.LoadFromStream

TppTemplate.LoadFromStream uses GlobalNameSpace.BeginWrite/EndWrite for "thred safety reading components". I'm familiar with GlobalNameSpace due to a deadlock scenario I encountered 15 years ago in Delphi 6. :(

I'm curious how safe it is to call TppTemplate.LoadFromStream from a thread other than the VCL thread. If I ensure that no code touches the TppReport and related objects (pipeline, data source, etc) until after LoadFromStream is finished, can a report template be loaded "in the background"?

FWIW, I'm currently using Delphi 11.3 and RB Enterprise Edition 22.03 Build 340.

Thanks

Comments

  • Hi Jon,

    We have not had any known issues with deadlocking and are confident in the thread safety of ReportBuilder.

    I am curious about your ultimate goal. Are you attempting to load a template in a background thread, then run the report in the main thread? Obviously you would need to be sure the report is not accessed while the template is being loaded but that begs the question: why load in a thread to begin with?
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited November 12
    why load in a thread to begin with?
    Apologies for the late reply. The templates in question have a WMF image as a background for the report. Those images were 1099 and W2 forms and the report printed on top of the background image. Unfortunately, the WMF images were raster bitmaps and not vector, so they were bulky and there was a noticeable delay when loading the templates.

    After posting my question, I implemented a thread to load the template and ensure that the user could not start the report until after the template was loaded. Each owning form has options for the report, which the user can change. Showing the form immediately and having the "Run Report" button disabled for a couple of seconds was better than delaying the appearance of the form. In that scenario, users may click the parent form's menu/toolbar/button multiple times due to impatience. ;)

    However, I have completely replaced that implementation with code that reads a PDF containing form fields, populates the form fields, and copies the rendered bitmap into an empty TppImage. Those reports no longer use a template at all. They are empty, aside from page/band settings and an empty TppImage.
Sign In or Register to comment.