mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 04:02:57 +08:00
More correctly handle fire-and-forget async call
This commit is contained in:
parent
91021eb8c4
commit
d27b83d678
@ -51,21 +51,25 @@ namespace osu.Game.Screens.Multi.RealtimeMultiplayer
|
||||
{
|
||||
if (!connected.NewValue)
|
||||
{
|
||||
startedEvent.Set();
|
||||
|
||||
// messaging to the user about this disconnect will be provided by the RealtimeMatchSubScreen.
|
||||
Schedule(PerformImmediateExit);
|
||||
failAndBail();
|
||||
}
|
||||
}, true);
|
||||
|
||||
client.ChangeState(MultiplayerUserState.Loaded);
|
||||
client.ChangeState(MultiplayerUserState.Loaded).ContinueWith(task =>
|
||||
failAndBail(task.Exception?.Message ?? "Server error"), TaskContinuationOptions.NotOnRanToCompletion);
|
||||
|
||||
if (!startedEvent.Wait(TimeSpan.FromSeconds(30)))
|
||||
{
|
||||
Logger.Log("Failed to start the multiplayer match in time.", LoggingTarget.Runtime, LogLevel.Important);
|
||||
failAndBail("Failed to start the multiplayer match in time.");
|
||||
}
|
||||
|
||||
Schedule(PerformImmediateExit);
|
||||
}
|
||||
private void failAndBail(string message = null)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(message))
|
||||
Logger.Log(message, LoggingTarget.Runtime, LogLevel.Important);
|
||||
|
||||
startedEvent.Set();
|
||||
Schedule(PerformImmediateExit);
|
||||
}
|
||||
|
||||
private void onMatchStarted() => startedEvent.Set();
|
||||
|
Loading…
Reference in New Issue
Block a user