diff --git a/osu.Game/Online/Multiplayer/StatefulMultiplayerClient.cs b/osu.Game/Online/Multiplayer/StatefulMultiplayerClient.cs
index fbdfb6a8c5..f0e11b2b8b 100644
--- a/osu.Game/Online/Multiplayer/StatefulMultiplayerClient.cs
+++ b/osu.Game/Online/Multiplayer/StatefulMultiplayerClient.cs
@@ -7,7 +7,6 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
-using System.Threading;
using System.Threading.Tasks;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
@@ -128,7 +127,8 @@ public async Task JoinRoom(Room room)
Debug.Assert(Room != null);
- var users = getRoomUsers();
+ var users = await getRoomUsers();
+ Debug.Assert(users != null);
await Task.WhenAll(users.Select(PopulateUser));
@@ -437,24 +437,20 @@ Task IMultiplayerClient.ResultsReady()
/// This should be used whenever accessing users from outside of an Update thread context (ie. when not calling ).
///
/// A copy of users in the current room, or null if unavailable.
- private List? getRoomUsers()
+ private Task?> getRoomUsers()
{
- List? users = null;
-
- ManualResetEventSlim resetEvent = new ManualResetEventSlim();
+ var tcs = new TaskCompletionSource?>();
// at some point we probably want to replace all these schedule calls with Room.LockForUpdate.
// for now, as this would require quite some consideration due to the number of accesses to the room instance,
// let's just add a manual schedule for the non-scheduled usages instead.
Scheduler.Add(() =>
{
- users = Room?.Users.ToList();
- resetEvent.Set();
+ var users = Room?.Users.ToList();
+ tcs.SetResult(users);
}, false);
- resetEvent.Wait(100);
-
- return users;
+ return tcs.Task;
}
///