From 62fc8f5286d88920a3421564af74f3c3f01c6bd3 Mon Sep 17 00:00:00 2001 From: David Sungaila Date: Mon, 25 Sep 2023 20:52:59 +0200 Subject: [PATCH] Fix Exception handling for WebConverter --- WebConverter/Pages/Index.razor.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/WebConverter/Pages/Index.razor.cs b/WebConverter/Pages/Index.razor.cs index 0e0215c..a97e8ba 100644 --- a/WebConverter/Pages/Index.razor.cs +++ b/WebConverter/Pages/Index.razor.cs @@ -118,7 +118,7 @@ private async Task Submit() Model.Input.Position = 0; bool encodeSuccess = false; - await Task.Factory.StartNew(async () => + await Task.Factory.StartNew(() => { SKBitmap inputToConvert; @@ -164,11 +164,13 @@ await Task.Factory.StartNew(async () => encodeSuccess = monochromeBitmap.Encode(Model.OutputPreviewImage, SKEncodedImageFormat.Png, 100); } } - - await SetImage(); }, TaskCreationOptions.LongRunning); - if (!encodeSuccess) + if (encodeSuccess) + { + await SetImage(); + } + else { Model.OutputPreviewImage?.Dispose(); Model.OutputPreviewImage = null;