From 9ec870a8219f4832b6552f5dd4acdc74994892ec Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 24 Oct 2017 11:50:18 +0900 Subject: [PATCH] Add comment pertaining to why Schedule() is required --- osu.Game/OsuGame.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index b8c197abc9..a278366e3e 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -277,6 +277,9 @@ namespace osu.Game private void loadComponentSingleFile(T d, Action add) where T : Drawable { + // schedule is here to ensure that all component loads are done after LoadComplete is run (and thus all dependencies are cached). + // with some better organisation of LoadComplete to do construction and dependency caching in one step, followed by calls to loadComponentSingleFile, + // we could avoid the need for scheduling altogether. Schedule(() => { asyncLoadStream = asyncLoadStream?.ContinueWith(t => LoadComponentAsync(d, add).Wait()) ?? LoadComponentAsync(d, add); }); }