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
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
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?
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
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.