mirror of https://github.com/ppy/osu
Add cancellation support
This commit is contained in:
parent
37a659b2af
commit
5cdc8d2e7b
|
@ -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<BeatmapDifficultyManager> diffic
|
|||
}
|
||||
|
||||
private IBindable<StarDifficulty> difficultyBindable;
|
||||
private CancellationTokenSource difficultyCancellationSource;
|
||||
|
||||
private void onScoringModeChanged(ValueChangedEvent<ScoringMode> mode)
|
||||
{
|
||||
difficultyCancellationSource?.Cancel();
|
||||
difficultyCancellationSource = null;
|
||||
|
||||
if (score.Beatmap == null)
|
||||
{
|
||||
Value = score.TotalScore;
|
||||
|
@ -156,7 +161,7 @@ private void onScoringModeChanged(ValueChangedEvent<ScoringMode> 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
|
||||
|
|
Loading…
Reference in New Issue