diff --git a/osu.Game/Rulesets/UI/DrawableRuleset.cs b/osu.Game/Rulesets/UI/DrawableRuleset.cs index 1215cfb626..37f53d552c 100644 --- a/osu.Game/Rulesets/UI/DrawableRuleset.cs +++ b/osu.Game/Rulesets/UI/DrawableRuleset.cs @@ -141,7 +141,7 @@ namespace osu.Game.Rulesets.UI public virtual PlayfieldAdjustmentContainer CreatePlayfieldAdjustmentContainer() => new PlayfieldAdjustmentContainer(); [BackgroundDependencyLoader] - private void load(OsuConfigManager config, CancellationToken cancellationToken) + private void load(OsuConfigManager config, CancellationToken? cancellationToken) { InternalChildren = new Drawable[] { @@ -170,18 +170,15 @@ namespace osu.Game.Rulesets.UI /// /// Creates and adds drawable representations of hit objects to the play field. /// - private void loadObjects(CancellationToken cancellationToken) + private void loadObjects(CancellationToken? cancellationToken) { foreach (TObject h in Beatmap.HitObjects) { - if (cancellationToken.IsCancellationRequested) - break; - + cancellationToken?.ThrowIfCancellationRequested(); addHitObject(h); } - if (cancellationToken.IsCancellationRequested) - return; + cancellationToken?.ThrowIfCancellationRequested(); Playfield.PostProcess(); diff --git a/osu.Game/Storyboards/Drawables/DrawableStoryboard.cs b/osu.Game/Storyboards/Drawables/DrawableStoryboard.cs index 6af9d4d7f9..2b27a56844 100644 --- a/osu.Game/Storyboards/Drawables/DrawableStoryboard.cs +++ b/osu.Game/Storyboards/Drawables/DrawableStoryboard.cs @@ -58,7 +58,7 @@ namespace osu.Game.Storyboards.Drawables } [BackgroundDependencyLoader(true)] - private void load(FileStore fileStore, GameplayClock clock, CancellationToken cancellationToken) + private void load(FileStore fileStore, GameplayClock clock, CancellationToken? cancellationToken) { if (clock != null) Clock = clock; @@ -67,8 +67,7 @@ namespace osu.Game.Storyboards.Drawables foreach (var layer in Storyboard.Layers) { - if (cancellationToken.IsCancellationRequested) - break; + cancellationToken?.ThrowIfCancellationRequested(); Add(layer.CreateDrawable()); } diff --git a/osu.Game/Storyboards/Drawables/DrawableStoryboardLayer.cs b/osu.Game/Storyboards/Drawables/DrawableStoryboardLayer.cs index e82b0df4f4..fd2d441f34 100644 --- a/osu.Game/Storyboards/Drawables/DrawableStoryboardLayer.cs +++ b/osu.Game/Storyboards/Drawables/DrawableStoryboardLayer.cs @@ -25,12 +25,11 @@ namespace osu.Game.Storyboards.Drawables } [BackgroundDependencyLoader] - private void load(CancellationToken cancellationToken) + private void load(CancellationToken? cancellationToken) { foreach (var element in Layer.Elements) { - if (cancellationToken.IsCancellationRequested) - break; + cancellationToken?.ThrowIfCancellationRequested(); if (element.IsDrawable) AddInternal(element.CreateDrawable());