1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 20:13:21 +08:00

Reduce code repetition for sleep logic

This commit is contained in:
Dean Herbert 2023-07-04 15:35:09 +09:00
parent 67650831bd
commit 1a6381bcbb

View File

@ -132,11 +132,7 @@ namespace osu.Game
foreach (var id in beatmapSetIds)
{
while (localUserPlayInfo?.IsPlaying.Value == true)
{
Logger.Log("Background processing sleeping due to active gameplay...");
Thread.Sleep(TimeToSleepDuringGameplay);
}
sleepIfRequired();
realmAccess.Run(r =>
{
@ -177,11 +173,7 @@ namespace osu.Game
foreach (var id in scoreIds)
{
while (localUserPlayInfo?.IsPlaying.Value == true)
{
Logger.Log("Background processing sleeping due to active gameplay...");
Thread.Sleep(TimeToSleepDuringGameplay);
}
sleepIfRequired();
try
{
@ -229,19 +221,17 @@ namespace osu.Game
ProgressNotification? notification = null;
if (scoreIds.Count > 0)
notificationOverlay?.Post(notification = new ProgressNotification { State = ProgressNotificationState.Active });
if (scoreIds.Count == 0)
return;
notificationOverlay?.Post(notification = new ProgressNotification { State = ProgressNotificationState.Active });
int count = 0;
updateNotification();
foreach (var id in scoreIds)
{
while (localUserPlayInfo?.IsPlaying.Value == true)
{
Logger.Log("Background processing sleeping due to active gameplay...");
Thread.Sleep(TimeToSleepDuringGameplay);
}
sleepIfRequired();
try
{
@ -286,5 +276,14 @@ namespace osu.Game
}
}
}
private void sleepIfRequired()
{
while (localUserPlayInfo?.IsPlaying.Value == true)
{
Logger.Log("Background processing sleeping due to active gameplay...");
Thread.Sleep(TimeToSleepDuringGameplay);
}
}
}
}