CompositionTarget.Rendered Event
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Occurs immediately after the core rendering process renders a frame. This event lets you determine how long each frame takes to render.
// Register
static event_token Rendered(EventHandler<RenderedEventArgs> const& handler) const;
// Revoke with event_token
static void Rendered(event_token const* cookie) const;
// Revoke with event_revoker
static CompositionTarget::Rendered_revoker Rendered(auto_revoke_t, EventHandler<RenderedEventArgs> const& handler) const;
public static event System.EventHandler<RenderedEventArgs> Rendered;
function onRendered(eventArgs) { /* Your code */ }
Windows.UI.Xaml.Media.CompositionTarget.addEventListener("rendered", onRendered);
Windows.UI.Xaml.Media.CompositionTarget.removeEventListener("rendered", onRendered);
- or -
Windows.UI.Xaml.Media.CompositionTarget.onrendered = onRendered;
Public Shared Custom Event Rendered As EventHandler(Of RenderedEventArgs)
Event Type
Windows requirements
Device family |
Windows 10, version 1803 (introduced in 10.0.17134.0)
|
API contract |
Windows.Foundation.UniversalApiContract (introduced in v6.0)
|
Remarks
Tip
We recommend that you use the Visual Studio Application Timeline profiler when developing and testing your application. It gives more detailed information on your application's resource consumption, including time spent preparing UI frames.
You can use the Rendered event to measure frame duration and application responsiveness at runtime without Visual Studio or a debugger attached. For example, this could be used to generate telemetry for apps after they are deployed, or to adjust the amount of custom DirectX rendering work an application is doing each frame.
A longer frame duration means your app had to perform more work before a frame could be rendered. Frame durations longer than approximately 16 milliseconds mean that your application is not able to update at the recommended frequency of 60 frames per second, and so the user might experience a noticeable delay in UI responsiveness.
If you do see long frame durations then consider profiling your application using the Visual Studio Application Timeline and implementing the recommended Performance best practices.
Handlers for Rendered run on the UI thread even though they're not tied to any specific UI element. It's a good idea to remove any Rendered handlers when you no longer need them, and add them only when you do need them.