diff --git a/osu.Game/Beatmaps/BeatmapDifficultyCache.cs b/osu.Game/Beatmaps/BeatmapDifficultyCache.cs index 0e4dab2b96..45dadc4e3f 100644 --- a/osu.Game/Beatmaps/BeatmapDifficultyCache.cs +++ b/osu.Game/Beatmaps/BeatmapDifficultyCache.cs @@ -262,7 +262,7 @@ namespace osu.Game.Beatmaps // GetDifficultyAsync will fall back to existing data from IBeatmapInfo if not locally available // (contrary to GetAsync) GetDifficultyAsync(bindable.BeatmapInfo, rulesetInfo, mods, cancellationToken) - .ContinueWith(t => + .ContinueWith(task => { // We're on a threadpool thread, but we should exit back to the update thread so consumers can safely handle value-changed events. Schedule(() => @@ -270,8 +270,10 @@ namespace osu.Game.Beatmaps if (cancellationToken.IsCancellationRequested) return; - if (t.WaitSafelyForResult() is StarDifficulty sd) - bindable.Value = sd; + var starDifficulty = task.GetCompletedResult(); + + if (starDifficulty != null) + bindable.Value = starDifficulty.Value; }); }, cancellationToken); } diff --git a/osu.Game/Database/OnlineLookupCache.cs b/osu.Game/Database/OnlineLookupCache.cs index b392336bb4..f5847428ee 100644 --- a/osu.Game/Database/OnlineLookupCache.cs +++ b/osu.Game/Database/OnlineLookupCache.cs @@ -59,7 +59,7 @@ namespace osu.Game.Database if (!task.IsCompletedSuccessfully) return null; - return task.WaitSafelyForResult(); + return task.GetCompletedResult(); }, token)); } diff --git a/osu.Game/Online/Chat/ChannelManager.cs b/osu.Game/Online/Chat/ChannelManager.cs index 3b27dd5c5d..52d5fa1642 100644 --- a/osu.Game/Online/Chat/ChannelManager.cs +++ b/osu.Game/Online/Chat/ChannelManager.cs @@ -536,8 +536,10 @@ namespace osu.Game.Online.Chat // Try to get user in order to open PM chat users.GetUserAsync((int)lastClosedChannel.Id).ContinueWith(task => { - if (task.WaitSafelyForResult() is APIUser u) - Schedule(() => CurrentChannel.Value = JoinChannel(new Channel(u))); + var user = task.GetCompletedResult(); + + if (user != null) + Schedule(() => CurrentChannel.Value = JoinChannel(new Channel(user))); }); } diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs index adb1adeed4..0f25be2d3c 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs @@ -85,7 +85,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores if (loadCancellationSource.IsCancellationRequested) return; - var scores = task.WaitSafelyForResult(); + var scores = task.GetCompletedResult(); var topScore = scores.First(); diff --git a/osu.Game/Overlays/Dashboard/CurrentlyPlayingDisplay.cs b/osu.Game/Overlays/Dashboard/CurrentlyPlayingDisplay.cs index b7d236c263..73b199f159 100644 --- a/osu.Game/Overlays/Dashboard/CurrentlyPlayingDisplay.cs +++ b/osu.Game/Overlays/Dashboard/CurrentlyPlayingDisplay.cs @@ -64,7 +64,7 @@ namespace osu.Game.Overlays.Dashboard { users.GetUserAsync(id).ContinueWith(task => { - var user = task.WaitSafelyForResult(); + var user = task.GetCompletedResult(); if (user == null) return; diff --git a/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs b/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs index 49eb80d993..8dbae420ac 100644 --- a/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs @@ -48,7 +48,7 @@ namespace osu.Game.Overlays.Settings.Sections.General checkForUpdatesButton.Enabled.Value = false; Task.Run(updateManager.CheckForUpdateAsync).ContinueWith(task => Schedule(() => { - if (!task.WaitSafelyForResult()) + if (!task.GetCompletedResult()) { notifications?.Post(new SimpleNotification { diff --git a/osu.Game/Scoring/ScoreManager.cs b/osu.Game/Scoring/ScoreManager.cs index 9715cd64a7..b4edb23689 100644 --- a/osu.Game/Scoring/ScoreManager.cs +++ b/osu.Game/Scoring/ScoreManager.cs @@ -113,7 +113,7 @@ namespace osu.Game.Scoring public void GetTotalScore([NotNull] ScoreInfo score, [NotNull] Action callback, ScoringMode mode = ScoringMode.Standardised, CancellationToken cancellationToken = default) { GetTotalScoreAsync(score, mode, cancellationToken) - .ContinueWith(task => scheduler.Add(() => callback(task.WaitSafelyForResult())), TaskContinuationOptions.OnlyOnRanToCompletion); + .ContinueWith(task => scheduler.Add(() => callback(task.GetCompletedResult())), TaskContinuationOptions.OnlyOnRanToCompletion); } /// diff --git a/osu.Game/Screens/Play/HUD/MultiplayerGameplayLeaderboard.cs b/osu.Game/Screens/Play/HUD/MultiplayerGameplayLeaderboard.cs index 6f2a76b3cb..c384d97229 100644 --- a/osu.Game/Screens/Play/HUD/MultiplayerGameplayLeaderboard.cs +++ b/osu.Game/Screens/Play/HUD/MultiplayerGameplayLeaderboard.cs @@ -79,7 +79,7 @@ namespace osu.Game.Screens.Play.HUD userLookupCache.GetUsersAsync(playingUsers.Select(u => u.UserID).ToArray()).ContinueWith(task => Schedule(() => { - var users = task.WaitSafelyForResult(); + var users = task.GetCompletedResult(); foreach (var user in users) { diff --git a/osu.Game/Screens/Play/HUD/PerformancePointsCounter.cs b/osu.Game/Screens/Play/HUD/PerformancePointsCounter.cs index f543cea15c..897678640f 100644 --- a/osu.Game/Screens/Play/HUD/PerformancePointsCounter.cs +++ b/osu.Game/Screens/Play/HUD/PerformancePointsCounter.cs @@ -76,7 +76,7 @@ namespace osu.Game.Screens.Play.HUD difficultyCache.GetTimedDifficultyAttributesAsync(gameplayWorkingBeatmap, gameplayState.Ruleset, clonedMods, loadCancellationSource.Token) .ContinueWith(task => Schedule(() => { - timedAttributes = task.WaitSafelyForResult(); + timedAttributes = task.GetCompletedResult(); IsValid = true; diff --git a/osu.Game/Screens/Ranking/Expanded/Statistics/PerformanceStatistic.cs b/osu.Game/Screens/Ranking/Expanded/Statistics/PerformanceStatistic.cs index 90ecd3642b..1d00043244 100644 --- a/osu.Game/Screens/Ranking/Expanded/Statistics/PerformanceStatistic.cs +++ b/osu.Game/Screens/Ranking/Expanded/Statistics/PerformanceStatistic.cs @@ -38,7 +38,7 @@ namespace osu.Game.Screens.Ranking.Expanded.Statistics else { performanceCache.CalculatePerformanceAsync(score, cancellationTokenSource.Token) - .ContinueWith(t => Schedule(() => setPerformanceValue(t.WaitSafelyForResult())), cancellationTokenSource.Token); + .ContinueWith(t => Schedule(() => setPerformanceValue(t.GetCompletedResult())), cancellationTokenSource.Token); } } diff --git a/osu.Game/Screens/Ranking/ScorePanelList.cs b/osu.Game/Screens/Ranking/ScorePanelList.cs index b29f2302d5..5ae6b9d417 100644 --- a/osu.Game/Screens/Ranking/ScorePanelList.cs +++ b/osu.Game/Screens/Ranking/ScorePanelList.cs @@ -154,7 +154,7 @@ namespace osu.Game.Screens.Ranking scoreManager.GetTotalScoreAsync(score) .ContinueWith(task => Schedule(() => { - flow.SetLayoutPosition(trackingContainer, task.WaitSafelyForResult()); + flow.SetLayoutPosition(trackingContainer, task.GetCompletedResult()); trackingContainer.Show(); diff --git a/osu.Game/Screens/Select/Details/AdvancedStats.cs b/osu.Game/Screens/Select/Details/AdvancedStats.cs index e7764b23be..dacc8c11e1 100644 --- a/osu.Game/Screens/Select/Details/AdvancedStats.cs +++ b/osu.Game/Screens/Select/Details/AdvancedStats.cs @@ -153,8 +153,8 @@ namespace osu.Game.Screens.Select.Details Task.WhenAll(normalStarDifficultyTask, moddedStarDifficultyTask).ContinueWith(_ => Schedule(() => { - var normalDifficulty = normalStarDifficultyTask.WaitSafelyForResult(); - var moddeDifficulty = moddedStarDifficultyTask.WaitSafelyForResult(); + var normalDifficulty = normalStarDifficultyTask.GetCompletedResult(); + var moddeDifficulty = moddedStarDifficultyTask.GetCompletedResult(); if (normalDifficulty == null || moddeDifficulty == null) return; diff --git a/osu.Game/Screens/Select/Leaderboards/BeatmapLeaderboard.cs b/osu.Game/Screens/Select/Leaderboards/BeatmapLeaderboard.cs index 6943f2a3b6..fbfca130ba 100644 --- a/osu.Game/Screens/Select/Leaderboards/BeatmapLeaderboard.cs +++ b/osu.Game/Screens/Select/Leaderboards/BeatmapLeaderboard.cs @@ -143,7 +143,7 @@ namespace osu.Game.Screens.Select.Leaderboards } scoreManager.OrderByTotalScoreAsync(scores.ToArray(), cancellationToken) - .ContinueWith(ordered => scoresCallback?.Invoke(ordered.WaitSafelyForResult()), TaskContinuationOptions.OnlyOnRanToCompletion); + .ContinueWith(task => scoresCallback?.Invoke(task.GetCompletedResult()), TaskContinuationOptions.OnlyOnRanToCompletion); return null; } @@ -184,7 +184,7 @@ namespace osu.Game.Screens.Select.Leaderboards if (cancellationToken.IsCancellationRequested) return; - scoresCallback?.Invoke(task.WaitSafelyForResult()); + scoresCallback?.Invoke(task.GetCompletedResult()); TopScore = r.UserScore?.CreateScoreInfo(rulesets, fetchBeatmapInfo); }), TaskContinuationOptions.OnlyOnRanToCompletion); }; diff --git a/osu.Game/Screens/Spectate/SpectatorScreen.cs b/osu.Game/Screens/Spectate/SpectatorScreen.cs index f361b0cee4..44a31d89ed 100644 --- a/osu.Game/Screens/Spectate/SpectatorScreen.cs +++ b/osu.Game/Screens/Spectate/SpectatorScreen.cs @@ -60,7 +60,7 @@ namespace osu.Game.Screens.Spectate userLookupCache.GetUsersAsync(users.ToArray()).ContinueWith(task => Schedule(() => { - var foundUsers = task.WaitSafelyForResult(); + var foundUsers = task.GetCompletedResult(); foreach (var u in foundUsers) { diff --git a/osu.Game/Tests/Beatmaps/BeatmapConversionTest.cs b/osu.Game/Tests/Beatmaps/BeatmapConversionTest.cs index 1b3e49de37..589857b458 100644 --- a/osu.Game/Tests/Beatmaps/BeatmapConversionTest.cs +++ b/osu.Game/Tests/Beatmaps/BeatmapConversionTest.cs @@ -148,7 +148,7 @@ namespace osu.Game.Tests.Beatmaps if (!conversionTask.Wait(10000)) Assert.Fail("Conversion timed out"); - return conversionTask.WaitSafelyForResult(); + return conversionTask.GetCompletedResult(); } protected virtual void OnConversionGenerated(HitObject original, IEnumerable result, IBeatmapConverter beatmapConverter)