Actually handle case of failing to achieve lock on SemaphoreSlim

This commit is contained in:
Dean Herbert 2021-02-05 14:08:11 +09:00
parent cd67fe1091
commit c5fa818630

View File

@ -67,7 +67,8 @@ namespace osu.Game.Online.Multiplayer
{ {
cancelExistingConnect(); cancelExistingConnect();
await connectionLock.WaitAsync(10000); if (!await connectionLock.WaitAsync(10000))
throw new TimeoutException("Could not obtain a lock to connect. A previous attempt is likely stuck.");
var builder = new HubConnectionBuilder() var builder = new HubConnectionBuilder()
.WithUrl(endpoint, options => { options.Headers.Add("Authorization", $"Bearer {api.AccessToken}"); }); .WithUrl(endpoint, options => { options.Headers.Add("Authorization", $"Bearer {api.AccessToken}"); });
@ -199,7 +200,10 @@ namespace osu.Game.Online.Multiplayer
cancelExistingConnect(); cancelExistingConnect();
if (takeLock) if (takeLock)
await connectionLock.WaitAsync(10000); {
if (!await connectionLock.WaitAsync(10000))
throw new TimeoutException("Could not obtain a lock to disconnect. A previous attempt is likely stuck.");
}
try try
{ {