From 2c9cc363348ba015766f03758f0b28ba357698cc Mon Sep 17 00:00:00 2001 From: pointfeev Date: Sun, 12 Jun 2022 00:22:32 -0500 Subject: [PATCH] fix exception disposal --- CreamInstaller/Forms/MainForm.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/CreamInstaller/Forms/MainForm.cs b/CreamInstaller/Forms/MainForm.cs index dc89d45..06667c2 100644 --- a/CreamInstaller/Forms/MainForm.cs +++ b/CreamInstaller/Forms/MainForm.cs @@ -68,8 +68,6 @@ internal partial class MainForm : CustomForm try { checkForUpdatesResult = await updateManager.CheckForUpdatesAsync(cancellationTokenSource.Token); - cancellationTokenSource.Dispose(); - cancellationTokenSource = null; #if !DEBUG if (checkForUpdatesResult.CanUpdate) { @@ -88,6 +86,11 @@ internal partial class MainForm : CustomForm #else catch { } #endif + finally + { + cancellationTokenSource.Dispose(); + cancellationTokenSource = null; + } } if (latestVersion is null) { @@ -203,6 +206,11 @@ internal partial class MainForm : CustomForm #else catch { } #endif + finally + { + cancellationTokenSource.Dispose(); + cancellationTokenSource = null; + } if (updateManager is not null && updateManager.IsUpdatePrepared(latestVersion)) {