mirror of
https://github.com/ppy/osu.git
synced 2025-02-20 04:23:14 +08:00
Update continuation usages to use GetCompletedResult
This commit is contained in:
parent
f9713b8895
commit
3ea7588a91
@ -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);
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ namespace osu.Game.Database
|
||||
if (!task.IsCompletedSuccessfully)
|
||||
return null;
|
||||
|
||||
return task.WaitSafelyForResult();
|
||||
return task.GetCompletedResult();
|
||||
}, token));
|
||||
}
|
||||
|
||||
|
@ -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)));
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -113,7 +113,7 @@ namespace osu.Game.Scoring
|
||||
public void GetTotalScore([NotNull] ScoreInfo score, [NotNull] Action<long> 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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
};
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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<HitObject> result, IBeatmapConverter beatmapConverter)
|
||||
|
Loading…
Reference in New Issue
Block a user