From eb8c4a27e5367eca2cccdb1cf4150cb6cba5dfa2 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 18 Jun 2025 18:29:36 +0900 Subject: [PATCH] Update cancellation token naming / inline comment slightly --- osu.Game/Updater/UpdateManager.cs | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/osu.Game/Updater/UpdateManager.cs b/osu.Game/Updater/UpdateManager.cs index ed19828998..a9b00e8f93 100644 --- a/osu.Game/Updater/UpdateManager.cs +++ b/osu.Game/Updater/UpdateManager.cs @@ -44,7 +44,8 @@ namespace osu.Game.Updater protected IBindable ReleaseStream => releaseStream; private readonly Bindable releaseStream = new Bindable(); - private CancellationTokenSource updateCancellation = new CancellationTokenSource(); + + private CancellationTokenSource updateCancellationSource = new CancellationTokenSource(); protected override void LoadComplete() { @@ -90,16 +91,13 @@ namespace osu.Game.Updater if (!CanCheckForUpdate) return false; - var cancellation = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken); - var lastCancellation = Interlocked.Exchange(ref updateCancellation, cancellation); + var cts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken); - using (lastCancellation) - { - // This serves a dual purpose of nullifying the last update, closing any existing notifications as stale. - await lastCancellation.CancelAsync().ConfigureAwait(false); - } + // Cancels the last update and closes any existing notifications as stale. + using (var lastCts = Interlocked.Exchange(ref updateCancellationSource, cts)) + await lastCts.CancelAsync().ConfigureAwait(false); - return await PerformUpdateCheck(cancellation.Token).ConfigureAwait(false); + return await PerformUpdateCheck(cts.Token).ConfigureAwait(false); } /// @@ -112,8 +110,8 @@ namespace osu.Game.Updater { base.Dispose(isDisposing); - updateCancellation.Cancel(); - updateCancellation.Dispose(); + updateCancellationSource.Cancel(); + updateCancellationSource.Dispose(); } private partial class UpdateCompleteNotification : SimpleNotification