Explain purpose of `Schedule` call in `MultiplayerPlayer.onResultsReady`

This commit is contained in:
Dean Herbert 2022-03-10 19:52:08 +09:00
parent 45d537ef72
commit 2d135e5be6
1 changed files with 5 additions and 3 deletions

View File

@ -175,10 +175,12 @@ private void onMatchStarted() => Scheduler.Add(() =>
base.StartGameplay();
});
private void onResultsReady() => Scheduler.Add(() =>
private void onResultsReady()
{
resultsReady.SetResult(true);
});
// Schedule is required to ensure that `TaskCompletionSource.SetResult` is not called more than once.
// A scenario where this can occur is if this instance is not immediately disposed (ie. async disposal queue).
Schedule(() => resultsReady.SetResult(true));
}
protected override async Task PrepareScoreForResultsAsync(Score score)
{