Show reports in separate threads

Stimulsoft Reports.WPF discussion
Post Reply
melzer
Posts: 17
Joined: Wed Oct 03, 2012 9:07 am

Show reports in separate threads

Post by melzer »

Hi,

what is the correct way to show multiple reports in a separate thread each?
The reason is that we use modal windows, and when you show a report in a window and change to a different window, the open report is not responsive any more.
When shown in an own thread, it is.

In Reports.NET we used this code, which worked fine:

public static void ShowReport(StiReport rpt) //rpt already filled with data and rendered
{
if (rpt == null) return;

Thread threadShowReport = new Thread(new ParameterizedThreadStart(ShowReport));
threadShowReport.SetApartmentState(ApartmentState.STA);
threadShowReport.IsBackground = true;
threadShowReport.Start(rpt);
}

public static void ShowReport(object obj)
{
((StiReport)obj).Show(true);
}

Recently we changed to Reports.WPF, and on the second call an exception is thrown:
"the calling thread cannot access this object because a different thread owns it"

Please help!
Lech Kulikowski
Posts: 6196
Joined: Tue Mar 20, 2018 5:34 am

Re: Show reports in separate threads

Post by Lech Kulikowski »

Hello,

Please send us a sample project that reproduces the issue for analysis.

Thank you.
melzer
Posts: 17
Joined: Wed Oct 03, 2012 9:07 am

Re: Show reports in separate threads

Post by melzer »

Here you are :-)
Attachments
ReportSample.zip
(673.27 KiB) Downloaded 154 times
Lech Kulikowski
Posts: 6196
Joined: Tue Mar 20, 2018 5:34 am

Re: Show reports in separate threads

Post by Lech Kulikowski »

Hello,

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

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

Re: Show reports in separate threads

Post by Lech Kulikowski »

Hello,

In your sample, you should change ShowDialog() on the Show() method.

Thank you.
melzer
Posts: 17
Joined: Wed Oct 03, 2012 9:07 am

Re: Show reports in separate threads

Post by melzer »

I know this would work :-)
But we need ShowDialog in certain cases...
Lech Kulikowski
Posts: 6196
Joined: Tue Mar 20, 2018 5:34 am

Re: Show reports in separate threads

Post by Lech Kulikowski »

Hello,

> But we need ShowDialog in certain cases...

Can you describe in more detail what for?

Thank you.
Post Reply