Show reports in separate threads
Posted: Tue Dec 06, 2022 4:49 pm
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!
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!