Make background update happens in update thread, and thread-safer.

This commit is contained in:
Huo Yaoyuan
2016-11-06 16:34:47 +08:00
parent d63e3b6724
commit 000c2218b8

View File

@ -249,13 +249,13 @@ namespace osu.Game.Overlays
private void play(BeatmapInfo info, bool? isNext) private void play(BeatmapInfo info, bool? isNext)
{ {
current = database.GetWorkingBeatmap(info, current); current = database.GetWorkingBeatmap(info, current);
Task.Factory.StartNew(() => Task.Run(() =>
{ {
trackManager.SetExclusive(current.Track); trackManager.SetExclusive(current.Track);
current.Track.Start(); current.Track.Start();
beatmapSource.Value = current; beatmapSource.Value = current;
updateCurrent(current, isNext);
}); });
updateCurrent(current, isNext);
} }
private void updateCurrent(WorkingBeatmap beatmap, bool? isNext) private void updateCurrent(WorkingBeatmap beatmap, bool? isNext)
@ -284,7 +284,7 @@ namespace osu.Game.Overlays
} }
else else
{ {
Remove(backgroundSprite); backgroundSprite.Expire();
} }
backgroundSprite = newBackground; backgroundSprite = newBackground;