diff --git a/osu.Game/Scoring/ScoreManager.cs b/osu.Game/Scoring/ScoreManager.cs index 5a6ef6945c..619ca76598 100644 --- a/osu.Game/Scoring/ScoreManager.cs +++ b/osu.Game/Scoring/ScoreManager.cs @@ -6,6 +6,7 @@ using System.IO; using System.Linq; using System.Linq.Expressions; +using System.Threading; using JetBrains.Annotations; using Microsoft.EntityFrameworkCore; using osu.Framework.Bindables; @@ -135,9 +136,13 @@ public TotalScoreBindable(ScoreInfo score, Func diffic } private IBindable difficultyBindable; + private CancellationTokenSource difficultyCancellationSource; private void onScoringModeChanged(ValueChangedEvent mode) { + difficultyCancellationSource?.Cancel(); + difficultyCancellationSource = null; + if (score.Beatmap == null) { Value = score.TotalScore; @@ -156,7 +161,7 @@ private void onScoringModeChanged(ValueChangedEvent mode) } // We can compute the max combo locally after the async beatmap difficulty computation. - difficultyBindable = difficulties().GetBindableDifficulty(score.Beatmap, score.Ruleset, score.Mods); + difficultyBindable = difficulties().GetBindableDifficulty(score.Beatmap, score.Ruleset, score.Mods, (difficultyCancellationSource = new CancellationTokenSource()).Token); difficultyBindable.BindValueChanged(d => updateScore(d.NewValue.MaxCombo), true); } else