RichText-Usage is not thread safe ?!

Stimulsoft Reports.NET discussion
Post Reply
rksaskia
Posts: 58
Joined: Fri Apr 27, 2012 9:16 am

RichText-Usage is not thread safe ?!

Post by rksaskia »

Hello,

see sample project.

6 Datasources, same report template, 6 tasks render and export parallel.
When i use lock(StiReport) around the Render And Export-Methode, all fine. All 6 Pdfs are generated.

But without lock, two errors may occur:
1. There are an infinite number of empty pages produced (one or more threads).
or
2. an exceptions occurs: "The object is already in use elsewhere", at System.Drawing.Graphics.get_DpiX()

Our analysis showed that the error only occurs when RichText controls are used in the report. In the test project you can switch this, if you parameterize the report constructor accordingly.
true: RichText-Controls are used
false:RichText-Controls are not used
Line 18: using (StiReport report = new Report(true/false))

The lock variante is not a solution for us, because our product use also the RTF-Support, because then the error occurs anyway.

I hope you can help.

Greetings
Attachments
StimulsoftTest.zip
(2.94 MiB) Downloaded 123 times
Lech Kulikowski
Posts: 6245
Joined: Tue Mar 20, 2018 5:34 am

Re: RichText-Usage is not thread safe ?!

Post by Lech Kulikowski »

Hello,

We need some additional time to investigate the issue, we will let you know about the result.

Thank you.
Lech Kulikowski
Posts: 6245
Joined: Tue Mar 20, 2018 5:34 am

Re: RichText-Usage is not thread safe ?!

Post by Lech Kulikowski »

Hello,

> an exceptions occurs: "The object is already in use elsewhere", at System.Drawing.Graphics.get_DpiX()

The issue is fixed, will be available in the next release build.

> There are an infinite number of empty pages produced (one or more threads).

We are using the standard NetFramework RichText component to show rich text.

As our tests have shown, this component works unstably with multithreading - sometimes it gives incorrect results when measuring text height (huge sizes), especially with heavy use. This happens especially often if extended libraries are used (ForceLoadExtendedRichTextLibrary=true;)
With the standard version, such problems also arise, but much less frequently.
Unfortunately, we can’t do anything here.

There is only the following workaround: to render reports without RichText in multithreading, and all reports with RichText to render in one separate stream sequentially.
Of course, the speed will be lower, but without bugs.

Thank you.
rksaskia
Posts: 58
Joined: Fri Apr 27, 2012 9:16 am

Re: RichText-Usage is not thread safe ?!

Post by rksaskia »

I've already thought something like that. RTF is bad.
Why don't you offer an alternative?
You go to the Web with big steps, why is no HTML control offered?

Our customers need the option to include formatted text in the reports:
- simple text formatting, size, appearance, color
- Tables, with colors and cell merrging
- Justification
- Images
- don't forget PDF -Export (not render as image!)

You should include this in your roadmap!!

Thank you.
Lech Kulikowski
Posts: 6245
Joined: Tue Mar 20, 2018 5:34 am

Re: RichText-Usage is not thread safe ?!

Post by Lech Kulikowski »

Hello,

There us such task in our to-do list but we can not say when it will be implemented.

Thank you.
Post Reply