mirror of
https://github.com/osukey/osukey.git
synced 2025-06-08 12:58:01 +09: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
|
// GetDifficultyAsync will fall back to existing data from IBeatmapInfo if not locally available
|
||||||
// (contrary to GetAsync)
|
// (contrary to GetAsync)
|
||||||
GetDifficultyAsync(bindable.BeatmapInfo, rulesetInfo, mods, cancellationToken)
|
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.
|
// We're on a threadpool thread, but we should exit back to the update thread so consumers can safely handle value-changed events.
|
||||||
Schedule(() =>
|
Schedule(() =>
|
||||||
@ -270,8 +270,10 @@ namespace osu.Game.Beatmaps
|
|||||||
if (cancellationToken.IsCancellationRequested)
|
if (cancellationToken.IsCancellationRequested)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (t.WaitSafelyForResult() is StarDifficulty sd)
|
var starDifficulty = task.GetCompletedResult();
|
||||||
bindable.Value = sd;
|
|
||||||
|
if (starDifficulty != null)
|
||||||
|
bindable.Value = starDifficulty.Value;
|
||||||
});
|
});
|
||||||
}, cancellationToken);
|
}, cancellationToken);
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ namespace osu.Game.Database
|
|||||||
if (!task.IsCompletedSuccessfully)
|
if (!task.IsCompletedSuccessfully)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
return task.WaitSafelyForResult();
|
return task.GetCompletedResult();
|
||||||
}, token));
|
}, token));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -536,8 +536,10 @@ namespace osu.Game.Online.Chat
|
|||||||
// Try to get user in order to open PM chat
|
// Try to get user in order to open PM chat
|
||||||
users.GetUserAsync((int)lastClosedChannel.Id).ContinueWith(task =>
|
users.GetUserAsync((int)lastClosedChannel.Id).ContinueWith(task =>
|
||||||
{
|
{
|
||||||
if (task.WaitSafelyForResult() is APIUser u)
|
var user = task.GetCompletedResult();
|
||||||
Schedule(() => CurrentChannel.Value = JoinChannel(new Channel(u)));
|
|
||||||
|
if (user != null)
|
||||||
|
Schedule(() => CurrentChannel.Value = JoinChannel(new Channel(user)));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
|||||||
if (loadCancellationSource.IsCancellationRequested)
|
if (loadCancellationSource.IsCancellationRequested)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var scores = task.WaitSafelyForResult();
|
var scores = task.GetCompletedResult();
|
||||||
|
|
||||||
var topScore = scores.First();
|
var topScore = scores.First();
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ namespace osu.Game.Overlays.Dashboard
|
|||||||
{
|
{
|
||||||
users.GetUserAsync(id).ContinueWith(task =>
|
users.GetUserAsync(id).ContinueWith(task =>
|
||||||
{
|
{
|
||||||
var user = task.WaitSafelyForResult();
|
var user = task.GetCompletedResult();
|
||||||
|
|
||||||
if (user == null) return;
|
if (user == null) return;
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ namespace osu.Game.Overlays.Settings.Sections.General
|
|||||||
checkForUpdatesButton.Enabled.Value = false;
|
checkForUpdatesButton.Enabled.Value = false;
|
||||||
Task.Run(updateManager.CheckForUpdateAsync).ContinueWith(task => Schedule(() =>
|
Task.Run(updateManager.CheckForUpdateAsync).ContinueWith(task => Schedule(() =>
|
||||||
{
|
{
|
||||||
if (!task.WaitSafelyForResult())
|
if (!task.GetCompletedResult())
|
||||||
{
|
{
|
||||||
notifications?.Post(new SimpleNotification
|
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)
|
public void GetTotalScore([NotNull] ScoreInfo score, [NotNull] Action<long> callback, ScoringMode mode = ScoringMode.Standardised, CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
GetTotalScoreAsync(score, mode, cancellationToken)
|
GetTotalScoreAsync(score, mode, cancellationToken)
|
||||||
.ContinueWith(task => scheduler.Add(() => callback(task.WaitSafelyForResult())), TaskContinuationOptions.OnlyOnRanToCompletion);
|
.ContinueWith(task => scheduler.Add(() => callback(task.GetCompletedResult())), TaskContinuationOptions.OnlyOnRanToCompletion);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -79,7 +79,7 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
|
|
||||||
userLookupCache.GetUsersAsync(playingUsers.Select(u => u.UserID).ToArray()).ContinueWith(task => Schedule(() =>
|
userLookupCache.GetUsersAsync(playingUsers.Select(u => u.UserID).ToArray()).ContinueWith(task => Schedule(() =>
|
||||||
{
|
{
|
||||||
var users = task.WaitSafelyForResult();
|
var users = task.GetCompletedResult();
|
||||||
|
|
||||||
foreach (var user in users)
|
foreach (var user in users)
|
||||||
{
|
{
|
||||||
|
@ -76,7 +76,7 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
difficultyCache.GetTimedDifficultyAttributesAsync(gameplayWorkingBeatmap, gameplayState.Ruleset, clonedMods, loadCancellationSource.Token)
|
difficultyCache.GetTimedDifficultyAttributesAsync(gameplayWorkingBeatmap, gameplayState.Ruleset, clonedMods, loadCancellationSource.Token)
|
||||||
.ContinueWith(task => Schedule(() =>
|
.ContinueWith(task => Schedule(() =>
|
||||||
{
|
{
|
||||||
timedAttributes = task.WaitSafelyForResult();
|
timedAttributes = task.GetCompletedResult();
|
||||||
|
|
||||||
IsValid = true;
|
IsValid = true;
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ namespace osu.Game.Screens.Ranking.Expanded.Statistics
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
performanceCache.CalculatePerformanceAsync(score, cancellationTokenSource.Token)
|
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)
|
scoreManager.GetTotalScoreAsync(score)
|
||||||
.ContinueWith(task => Schedule(() =>
|
.ContinueWith(task => Schedule(() =>
|
||||||
{
|
{
|
||||||
flow.SetLayoutPosition(trackingContainer, task.WaitSafelyForResult());
|
flow.SetLayoutPosition(trackingContainer, task.GetCompletedResult());
|
||||||
|
|
||||||
trackingContainer.Show();
|
trackingContainer.Show();
|
||||||
|
|
||||||
|
@ -153,8 +153,8 @@ namespace osu.Game.Screens.Select.Details
|
|||||||
|
|
||||||
Task.WhenAll(normalStarDifficultyTask, moddedStarDifficultyTask).ContinueWith(_ => Schedule(() =>
|
Task.WhenAll(normalStarDifficultyTask, moddedStarDifficultyTask).ContinueWith(_ => Schedule(() =>
|
||||||
{
|
{
|
||||||
var normalDifficulty = normalStarDifficultyTask.WaitSafelyForResult();
|
var normalDifficulty = normalStarDifficultyTask.GetCompletedResult();
|
||||||
var moddeDifficulty = moddedStarDifficultyTask.WaitSafelyForResult();
|
var moddeDifficulty = moddedStarDifficultyTask.GetCompletedResult();
|
||||||
|
|
||||||
if (normalDifficulty == null || moddeDifficulty == null)
|
if (normalDifficulty == null || moddeDifficulty == null)
|
||||||
return;
|
return;
|
||||||
|
@ -143,7 +143,7 @@ namespace osu.Game.Screens.Select.Leaderboards
|
|||||||
}
|
}
|
||||||
|
|
||||||
scoreManager.OrderByTotalScoreAsync(scores.ToArray(), cancellationToken)
|
scoreManager.OrderByTotalScoreAsync(scores.ToArray(), cancellationToken)
|
||||||
.ContinueWith(ordered => scoresCallback?.Invoke(ordered.WaitSafelyForResult()), TaskContinuationOptions.OnlyOnRanToCompletion);
|
.ContinueWith(task => scoresCallback?.Invoke(task.GetCompletedResult()), TaskContinuationOptions.OnlyOnRanToCompletion);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -184,7 +184,7 @@ namespace osu.Game.Screens.Select.Leaderboards
|
|||||||
if (cancellationToken.IsCancellationRequested)
|
if (cancellationToken.IsCancellationRequested)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
scoresCallback?.Invoke(task.WaitSafelyForResult());
|
scoresCallback?.Invoke(task.GetCompletedResult());
|
||||||
TopScore = r.UserScore?.CreateScoreInfo(rulesets, fetchBeatmapInfo);
|
TopScore = r.UserScore?.CreateScoreInfo(rulesets, fetchBeatmapInfo);
|
||||||
}), TaskContinuationOptions.OnlyOnRanToCompletion);
|
}), TaskContinuationOptions.OnlyOnRanToCompletion);
|
||||||
};
|
};
|
||||||
|
@ -60,7 +60,7 @@ namespace osu.Game.Screens.Spectate
|
|||||||
|
|
||||||
userLookupCache.GetUsersAsync(users.ToArray()).ContinueWith(task => Schedule(() =>
|
userLookupCache.GetUsersAsync(users.ToArray()).ContinueWith(task => Schedule(() =>
|
||||||
{
|
{
|
||||||
var foundUsers = task.WaitSafelyForResult();
|
var foundUsers = task.GetCompletedResult();
|
||||||
|
|
||||||
foreach (var u in foundUsers)
|
foreach (var u in foundUsers)
|
||||||
{
|
{
|
||||||
|
@ -148,7 +148,7 @@ namespace osu.Game.Tests.Beatmaps
|
|||||||
if (!conversionTask.Wait(10000))
|
if (!conversionTask.Wait(10000))
|
||||||
Assert.Fail("Conversion timed out");
|
Assert.Fail("Conversion timed out");
|
||||||
|
|
||||||
return conversionTask.WaitSafelyForResult();
|
return conversionTask.GetCompletedResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void OnConversionGenerated(HitObject original, IEnumerable<HitObject> result, IBeatmapConverter beatmapConverter)
|
protected virtual void OnConversionGenerated(HitObject original, IEnumerable<HitObject> result, IBeatmapConverter beatmapConverter)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user