mirror of
https://github.com/osukey/osukey.git
synced 2025-05-20 21:17:32 +09: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.Containers;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Framework.Graphics.Textures;
|
using osu.Framework.Graphics.Textures;
|
||||||
using osu.Framework.Platform;
|
|
||||||
using osu.Game;
|
using osu.Game;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
@ -24,15 +23,13 @@ namespace osu.Desktop.Overlays
|
|||||||
private OsuConfigManager config;
|
private OsuConfigManager config;
|
||||||
private OsuGameBase game;
|
private OsuGameBase game;
|
||||||
private NotificationOverlay notificationOverlay;
|
private NotificationOverlay notificationOverlay;
|
||||||
private GameHost host;
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[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;
|
notificationOverlay = notification;
|
||||||
this.config = config;
|
this.config = config;
|
||||||
this.game = game;
|
this.game = game;
|
||||||
this.host = host;
|
|
||||||
|
|
||||||
AutoSizeAxes = Axes.Both;
|
AutoSizeAxes = Axes.Both;
|
||||||
Anchor = Anchor.BottomCentre;
|
Anchor = Anchor.BottomCentre;
|
||||||
|
@ -168,12 +168,10 @@ namespace osu.Game.Overlays
|
|||||||
if (initialFetchTask != null)
|
if (initialFetchTask != null)
|
||||||
return initialFetchTask;
|
return initialFetchTask;
|
||||||
|
|
||||||
var tcs = new TaskCompletionSource<bool>();
|
return initialFetchTask = Task.Run(async () =>
|
||||||
|
|
||||||
initialFetchTask = tcs.Task;
|
|
||||||
|
|
||||||
Task.Run(() =>
|
|
||||||
{
|
{
|
||||||
|
var tcs = new TaskCompletionSource<bool>();
|
||||||
|
|
||||||
var req = new GetChangelogRequest();
|
var req = new GetChangelogRequest();
|
||||||
req.Success += res =>
|
req.Success += res =>
|
||||||
{
|
{
|
||||||
@ -190,9 +188,9 @@ namespace osu.Game.Overlays
|
|||||||
};
|
};
|
||||||
req.Failure += _ => initialFetchTask = null;
|
req.Failure += _ => initialFetchTask = null;
|
||||||
req.Perform(API);
|
req.Perform(API);
|
||||||
});
|
|
||||||
|
|
||||||
return initialFetchTask;
|
await tcs.Task;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private CancellationTokenSource loadContentTask;
|
private CancellationTokenSource loadContentTask;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user