Esempio n. 1
0
        protected async void OnButtonCreateReportClicked(object sender, EventArgs e)
        {
            ViewModel.ReportGenerationCancelationTokenSource = new CancellationTokenSource();

            ViewModel.IsGenerating = true;

            _generationTask = Task.Run(async() =>
            {
                try
                {
                    var report = await ViewModel.ActionGenerateReport(ViewModel.ReportGenerationCancelationTokenSource.Token);

                    Application.Invoke((s, eventArgs) => { ViewModel.Report = report; });
                }
                catch (OperationCanceledException)
                {
                    Application.Invoke((s, eventArgs) => { ViewModel.ShowWarning("Формирование отчета было прервано"); });
                }
                catch (Exception ex)
                {
                    Application.Invoke((s, eventArgs) => { throw ex; });
                }
                finally
                {
                    Application.Invoke((s, eventArgs) => { ViewModel.IsGenerating = false; });
                }
            }, ViewModel.ReportGenerationCancelationTokenSource.Token);

            await _generationTask;
        }
Esempio n. 2
0
 protected void OnYbuttonCreateReportClicked(object sender, EventArgs e)
 {
     ViewModel.ReportGenerationCancelationTokenSource = new CancellationTokenSource();
     try
     {
         ViewModel.Report = ViewModel.ActionGenerateReport(ViewModel.ReportGenerationCancelationTokenSource.Token);
         datatreeviewDocuments.SetItemsSource(ViewModel.Report.Rows);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }