我想使用 Mvvm 模式在带有进度指示器的 DocumentViewer 上传递一些内容,这一代将在从 db 异步获取数据后使用 UiElements。
public async void ProcessReportAsync(){
IsBusy = true;
_reportDal = new ReportDal(_sprocName,_sprocParams);
ReportContainers = new ObservableCollection<ReportContainerViewModel>();
await Task.Run(() => _reportDal.InitReportDal());
ReportDataTable = _reportDal.DataTableReport;
await Task.Run(() => ProcessedElements());
var t3 = Task.Run(() => ProcessPage(_reportPage));
var t4 = Task.Run(() => ProcessContainerData());
await Task.WhenAll(t3, t4);
var p = new PrinterViewModel(this);
// This statement does'nt complete its execuation, which is adding more UIElements
if(DispatcherHelper.UIDispatcher.CheckAccess()) {
DispatcherHelper.UIDispatcher.Invoke(
()=>_document = p.CreateDocument(new Size(p.PrintDialog.PrintableAreaWidth,p.PrintDialog.PrintableAreaHeight))
,DispatcherPriority.Background);
}
// Can't reach this code
IsBusy = false;
}