Skip to content

Commit

Permalink
Fix Exception handling for WebConverter
Browse files Browse the repository at this point in the history
  • Loading branch information
sungaila committed Sep 25, 2023
1 parent 70eec7e commit 62fc8f5
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions WebConverter/Pages/Index.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 62fc8f5

Please sign in to comment.