Fix ongoing operation being begun in an async context

This commit is contained in:
Dean Herbert 2021-07-02 16:04:51 +09:00
parent f2d9d78455
commit 7b0f970e7d
2 changed files with 32 additions and 20 deletions

View File

@ -66,19 +66,23 @@ namespace osu.Game.Tests.Visual.Multiplayer
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = new Vector2(200, 50),
OnReadyClick = () => Task.Run(async () =>
OnReadyClick = () =>
{
readyClickOperation = OngoingOperationTracker.BeginOperation();
if (Client.IsHost && Client.LocalUser?.State == MultiplayerUserState.Ready)
Task.Run(async () =>
{
await Client.StartMatch();
return;
}
if (Client.IsHost && Client.LocalUser?.State == MultiplayerUserState.Ready)
{
await Client.StartMatch();
return;
}
await Client.ToggleReady();
readyClickOperation.Dispose();
})
await Client.ToggleReady();
readyClickOperation.Dispose();
});
}
});
});

View File

@ -70,31 +70,39 @@ namespace osu.Game.Tests.Visual.Multiplayer
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = new Vector2(200, 50),
OnSpectateClick = () => Task.Run(async () =>
OnSpectateClick = () =>
{
readyClickOperation = OngoingOperationTracker.BeginOperation();
await Client.ToggleSpectate();
readyClickOperation.Dispose();
})
Task.Run(async () =>
{
await Client.ToggleSpectate();
readyClickOperation.Dispose();
});
}
},
readyButton = new MultiplayerReadyButton
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = new Vector2(200, 50),
OnReadyClick = () => Task.Run(async () =>
OnReadyClick = () =>
{
readyClickOperation = OngoingOperationTracker.BeginOperation();
if (Client.IsHost && Client.LocalUser?.State == MultiplayerUserState.Ready)
Task.Run(async () =>
{
await Client.StartMatch();
return;
}
if (Client.IsHost && Client.LocalUser?.State == MultiplayerUserState.Ready)
{
await Client.StartMatch();
return;
}
await Client.ToggleReady();
readyClickOperation.Dispose();
})
await Client.ToggleReady();
readyClickOperation.Dispose();
});
}
}
}
};