I have a problem where it takes a few seconds to generate a report and send it to the printer (creating the RDLC report container is slow).
To make sure the user is aware of what is going on I attempted to update a status line before and after doing the print//.
Status = "Printing Report.";
OnPropertyChanged("Status");
//Create a hidden window to host the report control
ReportWindow rw = new ReportWindow();
rw.PrintReport();
rw.Close();
Status = "Printing Report complete.";
OnPropertyChanged("Status");
What I wanted to happen was:
- Status is updated indicating that the report is being created and will be printed as soon as its done.
- The report is created and printed over several seconds.
- Status is updated to show success.
What actually happens is:
- Nothing is shown on the UI
- After a few seconds, the report is created and printed
- Status is updated indicating that the report is being created and will be printed as soon as its done.
- Immediately afterwards status is updated to show success. This happens fast enough that the first message is at most strobed on the screen for a single screen refresh; at worst it's never seen at all unless I interrupt with a break point.
I've had similar issues before with WPF prioritizing doing something slow on the UI thread above updating the UI to indicate that it's going to be busy for a few seconds; but in this case I'm not able to remove the heavy item from the UI thread (or do something else) to avoid the issue.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…