private async void onUpdateFrame(object sender, FrameEventArgs e)
{
if (_updateFrameRetries > 3)
{
return;
}
try
{
_updateMessagePump.PumpMessages();
_repeatArgs.DeltaTime = e.Time;
await Events.OnRepeatedlyExecuteAlways.InvokeAsync(_repeatArgs);
if (State.Paused)
{
return;
}
adjustSpeed();
GameLoop.Update();
//Invoking repeatedly execute asynchronously, as if one subscriber is waiting on another subscriber the event will
//never get to it (for example: calling ChangeRoom from within RepeatedlyExecute calls StopWalking which
//waits for the walk to stop, only the walk also happens on RepeatedlyExecute and we'll hang.
//Since we're running asynchronously, the next UpdateFrame will call RepeatedlyExecute for the walk cycle to stop itself and we're good.
///The downside of this approach is that we need to look out for re-entrancy issues.
await Events.OnRepeatedlyExecute.InvokeAsync(_repeatArgs);
_pipeline?.Update();
}
catch (Exception ex)
{
_updateFrameRetries++;
Debug.WriteLine(ex.ToString());
throw ex;
}
}