var printItem = new MenuItem { Header = "Print..." };printItem.Click += (sender, e) => {
var reportSection = new EmbeddedVisualReportSection(this); var report = new Report(); report.Sections.Add(reportSection); report.Export(OutputFormat.XPS, @"c:\test.xps"); // Exports fine the entire grid. report.Print(); //throws CrossThread exception
};gridMenu.Items.Add(printItem);
What could be the reason?
Sam,
Sorry for not being clear. Rewind, here is the scenario:
- this is an app with multiple UI threads
- the grids could be running on any of those UI threads
- of course the printing would be done in the same thread as the grid was created in
- however, it would not work, but would yield exception as per above
Printing only would work as the grid (and the printed report) are running in the application "main thread"
-> Basically you can't have the grids running outside the main thread
Please let me know if the issue still would not be clear and you needed more info.
Thanks
Dierk,
The Report object is not thread safe. You would need to be on the same UI thread.
Sam
You just need to run into scenario where report is created on different thread than app main thread.
PrintDialog is causing the issue since.
Everything works fine with single threaded application.
Hello Dierk,
I tested it on a small sample and the report.Print() does not produce an error. Can you provide a sample that demonstrates the issue?
Thank you,
This item now is pending since several weeks. As a "paying" customer I would think it's reasonable to expect some feedback on that issue.
Infragistics support: would you mind providing some info on that matter or let us know if the scenario provided above would not be clear enough?
Thanks in advance