mirror of
https://github.com/ppy/osu.git
synced 2025-02-15 14:23:02 +08:00
Ensure only one update check can be running at a time
This commit is contained in:
parent
6beb28b685
commit
3dd642a336
@ -44,12 +44,22 @@ namespace osu.Game.Updater
|
||||
config.Set(OsuSetting.Version, game.Version);
|
||||
}
|
||||
|
||||
private readonly object updateTaskLock = new object();
|
||||
|
||||
private Task updateCheckTask;
|
||||
|
||||
public async Task CheckForUpdateAsync()
|
||||
{
|
||||
if (!CanCheckForUpdate)
|
||||
return;
|
||||
|
||||
await PerformUpdateCheck();
|
||||
lock (updateTaskLock)
|
||||
updateCheckTask ??= PerformUpdateCheck();
|
||||
|
||||
await updateCheckTask;
|
||||
|
||||
lock (updateTaskLock)
|
||||
updateCheckTask = null;
|
||||
}
|
||||
|
||||
protected virtual Task PerformUpdateCheck()
|
||||
|
Loading…
Reference in New Issue
Block a user