Page 1 of 1

Show reports in separate threads

Posted: Tue Dec 06, 2022 4:49 pm
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!

Re: Show reports in separate threads

Posted: Thu Dec 08, 2022 10:15 am
by Lech Kulikowski
Hello,

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

Thank you.

Re: Show reports in separate threads

Posted: Fri Dec 23, 2022 11:14 am
by melzer
Here you are :-)

Re: Show reports in separate threads

Posted: Fri Dec 23, 2022 2:25 pm
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

Re: Show reports in separate threads

Posted: Tue Dec 27, 2022 2:47 pm
by Lech Kulikowski
Hello,

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

Thank you.

Re: Show reports in separate threads

Posted: Wed Jan 04, 2023 11:05 am
by melzer
I know this would work :-)
But we need ShowDialog in certain cases...

Re: Show reports in separate threads

Posted: Wed Jan 04, 2023 1:30 pm
by Lech Kulikowski
Hello,

> But we need ShowDialog in certain cases...

Can you describe in more detail what for?

Thank you.