Make operation run asynchronously

This commit is contained in:
Dean Herbert 2019-03-01 10:09:03 +09:00
parent 798bc1306b
commit acc2113027
1 changed files with 11 additions and 10 deletions

View File

@ -8,20 +8,15 @@
using osu.Game.Scoring;
using System;
using System.Linq;
using System.Threading.Tasks;
namespace osu.Game.Screens.Select
{
public class BeatmapClearScoresDialog : PopupDialog
{
private ScoreManager manager;
private ScoreManager scoreManager;
[BackgroundDependencyLoader]
private void load(ScoreManager scoreManager)
{
manager = scoreManager;
}
public BeatmapClearScoresDialog(BeatmapInfo beatmap, Action refresh)
public BeatmapClearScoresDialog(BeatmapInfo beatmap, Action onCompletion)
{
BodyText = $@"{beatmap.Metadata?.Artist} - {beatmap.Metadata?.Title}";
Icon = FontAwesome.fa_eraser;
@ -33,8 +28,8 @@ public BeatmapClearScoresDialog(BeatmapInfo beatmap, Action refresh)
Text = @"Yes. Please.",
Action = () =>
{
manager.Delete(manager.QueryScores(s => !s.DeletePending && s.Beatmap.ID == beatmap.ID).ToList());
refresh();
Task.Run(() => scoreManager.Delete(scoreManager.QueryScores(s => !s.DeletePending && s.Beatmap.ID == beatmap.ID).ToList()))
.ContinueWith(t => Schedule(onCompletion));
}
},
new PopupDialogCancelButton
@ -43,5 +38,11 @@ public BeatmapClearScoresDialog(BeatmapInfo beatmap, Action refresh)
},
};
}
[BackgroundDependencyLoader]
private void load(ScoreManager scoreManager)
{
this.scoreManager = scoreManager;
}
}
}