Beispiel #1
0
        protected async Task CreateAndProcessDiagramImageAsync(Action <BitmapSource> imageProcessingAction, string imageProcessingMessage)
        {
            // Using int.MaxValue for max progress because the real max value is not yet known.
            using (var progressDialog = UiServices.CreateProgressDialog("Generating image..", int.MaxValue))
            {
                progressDialog.ShowProgressNumber = false;
                progressDialog.ShowWithDelayAsync();

                try
                {
                    var bitmapSource = await UiServices.CreateDiagramImageAsync(progressDialog.CancellationToken,
                                                                                progressDialog.Progress, progressDialog.MaxProgress);

                    if (bitmapSource != null)
                    {
                        progressDialog.Reset(imageProcessingMessage, showProgressNumber: false);
                        await Task.Factory.StartSTA(() => imageProcessingAction(bitmapSource), progressDialog.CancellationToken);
                    }
                }
                catch (OperationCanceledException)
                {
                }
            }
        }