-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make UiThreadRenderTimer to calculate the next tick time based on expected FPS #17121
Conversation
98e46a5
to
dcaceb1
Compare
return !cancelled; | ||
}, TimeSpan.FromSeconds(1.0 / FramesPerSecond), DispatcherPriority.UiThreadRender); | ||
return Disposable.Create(() => cancelled = true); | ||
_tick?.Invoke(tickedAt); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: _tick
is never null
, ?
can be removed.
} | ||
|
||
private static readonly TimeSpan s_minInterval = TimeSpan.FromMilliseconds(1); | ||
private TimeSpan Interval => TimeSpan.FromSeconds(1.0 / _parent.FramesPerSecond); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since FramesPerSecond
can't change, the frame interval can probably be computed only once in the constructor.
You can test this PR using the following package version. |
|
|
@maxkatz6 OK, I did notice the PrivateApi attribute was removed here as well. |
You can test this PR using the following package version. |
DispatcherTimer.Interval indicates the interval between the previous tick completion and the next one. Render timer, on the other hand, needs to have its interval to indicate time between tick starts.