From a19bb1270d3ef6a5a4f087832b716be58d1cb5d0 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Sun, 6 Nov 2016 00:46:09 +0800 Subject: [PATCH] Async workflow on music controller. --- osu.Game/Overlays/MusicController.cs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index 7ce13f736d..8f448b68a1 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; +using System.Threading.Tasks; using OpenTK; using OpenTK.Graphics; using osu.Framework; @@ -177,13 +178,18 @@ namespace osu.Game.Overlays beatmapSource = osuGame?.Beatmap ?? new Bindable(); beatmapSource.ValueChanged += workingChanged; - workingChanged(); playList = database.GetAllWithChildren(); backgroundSprite = getScaledSprite(game.Textures.Get(@"Backgrounds/bg4")); AddInternal(backgroundSprite); } + protected override void LoadComplete() + { + workingChanged(); + base.LoadComplete(); + } + protected override void Update() { base.Update(); @@ -240,10 +246,13 @@ namespace osu.Game.Overlays private void play(BeatmapInfo info, bool? isNext) { current = database.GetWorkingBeatmap(info, current); - trackManager.SetExclusive(current.Track); - current.Track.Start(); - beatmapSource.Value = current; - updateCurrent(current, isNext); + Task.Factory.StartNew(() => + { + trackManager.SetExclusive(current.Track); + current.Track.Start(); + beatmapSource.Value = current; + updateCurrent(current, isNext); + }); } private void updateCurrent(WorkingBeatmap beatmap, bool? isNext)