mirror of
https://github.com/ppy/osu
synced 2025-01-06 14:20:03 +00:00
Reduce code repetition for sleep logic
This commit is contained in:
parent
67650831bd
commit
1a6381bcbb
@ -132,11 +132,7 @@ namespace osu.Game
|
|||||||
|
|
||||||
foreach (var id in beatmapSetIds)
|
foreach (var id in beatmapSetIds)
|
||||||
{
|
{
|
||||||
while (localUserPlayInfo?.IsPlaying.Value == true)
|
sleepIfRequired();
|
||||||
{
|
|
||||||
Logger.Log("Background processing sleeping due to active gameplay...");
|
|
||||||
Thread.Sleep(TimeToSleepDuringGameplay);
|
|
||||||
}
|
|
||||||
|
|
||||||
realmAccess.Run(r =>
|
realmAccess.Run(r =>
|
||||||
{
|
{
|
||||||
@ -177,11 +173,7 @@ namespace osu.Game
|
|||||||
|
|
||||||
foreach (var id in scoreIds)
|
foreach (var id in scoreIds)
|
||||||
{
|
{
|
||||||
while (localUserPlayInfo?.IsPlaying.Value == true)
|
sleepIfRequired();
|
||||||
{
|
|
||||||
Logger.Log("Background processing sleeping due to active gameplay...");
|
|
||||||
Thread.Sleep(TimeToSleepDuringGameplay);
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -229,19 +221,17 @@ namespace osu.Game
|
|||||||
|
|
||||||
ProgressNotification? notification = null;
|
ProgressNotification? notification = null;
|
||||||
|
|
||||||
if (scoreIds.Count > 0)
|
if (scoreIds.Count == 0)
|
||||||
notificationOverlay?.Post(notification = new ProgressNotification { State = ProgressNotificationState.Active });
|
return;
|
||||||
|
|
||||||
|
notificationOverlay?.Post(notification = new ProgressNotification { State = ProgressNotificationState.Active });
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
updateNotification();
|
updateNotification();
|
||||||
|
|
||||||
foreach (var id in scoreIds)
|
foreach (var id in scoreIds)
|
||||||
{
|
{
|
||||||
while (localUserPlayInfo?.IsPlaying.Value == true)
|
sleepIfRequired();
|
||||||
{
|
|
||||||
Logger.Log("Background processing sleeping due to active gameplay...");
|
|
||||||
Thread.Sleep(TimeToSleepDuringGameplay);
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user