mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 07:42:57 +08:00
Use TaskCompletionSource in a better manner
This commit is contained in:
parent
acaf2f9fbb
commit
e034b3d514
@ -6,7 +6,6 @@ using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Game;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Graphics;
|
||||
@ -24,15 +23,13 @@ namespace osu.Desktop.Overlays
|
||||
private OsuConfigManager config;
|
||||
private OsuGameBase game;
|
||||
private NotificationOverlay notificationOverlay;
|
||||
private GameHost host;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(NotificationOverlay notification, OsuColour colours, TextureStore textures, OsuGameBase game, OsuConfigManager config, GameHost host)
|
||||
private void load(NotificationOverlay notification, OsuColour colours, TextureStore textures, OsuGameBase game, OsuConfigManager config)
|
||||
{
|
||||
notificationOverlay = notification;
|
||||
this.config = config;
|
||||
this.game = game;
|
||||
this.host = host;
|
||||
|
||||
AutoSizeAxes = Axes.Both;
|
||||
Anchor = Anchor.BottomCentre;
|
||||
|
@ -168,12 +168,10 @@ namespace osu.Game.Overlays
|
||||
if (initialFetchTask != null)
|
||||
return initialFetchTask;
|
||||
|
||||
var tcs = new TaskCompletionSource<bool>();
|
||||
|
||||
initialFetchTask = tcs.Task;
|
||||
|
||||
Task.Run(() =>
|
||||
return initialFetchTask = Task.Run(async () =>
|
||||
{
|
||||
var tcs = new TaskCompletionSource<bool>();
|
||||
|
||||
var req = new GetChangelogRequest();
|
||||
req.Success += res =>
|
||||
{
|
||||
@ -190,9 +188,9 @@ namespace osu.Game.Overlays
|
||||
};
|
||||
req.Failure += _ => initialFetchTask = null;
|
||||
req.Perform(API);
|
||||
});
|
||||
|
||||
return initialFetchTask;
|
||||
await tcs.Task;
|
||||
});
|
||||
}
|
||||
|
||||
private CancellationTokenSource loadContentTask;
|
||||
|
Loading…
Reference in New Issue
Block a user