Handle task exception outside of schedule to avoid unobserved exceptions

This commit is contained in:
Dean Herbert 2022-06-28 15:09:28 +09:00
parent a2701a3205
commit 22b254e5c5

View File

@ -294,17 +294,21 @@ namespace osu.Game.Online.Spectator
lastSend = tcs.Task; lastSend = tcs.Task;
SendFramesInternal(bundle).ContinueWith(t => Schedule(() => SendFramesInternal(bundle).ContinueWith(t =>
{ {
// Handle exception outside of `Schedule` to ensure it doesn't go unovserved.
bool wasSuccessful = t.Exception == null; bool wasSuccessful = t.Exception == null;
// If the last bundle send wasn't successful, try again without dequeuing. return Schedule(() =>
if (wasSuccessful) {
pendingFrameBundles.Dequeue(); // If the last bundle send wasn't successful, try again without dequeuing.
if (wasSuccessful)
pendingFrameBundles.Dequeue();
tcs.SetResult(wasSuccessful); tcs.SetResult(wasSuccessful);
sendNextBundleIfRequired(); sendNextBundleIfRequired();
})); });
});
} }
} }
} }