CompositionTarget.Rendering CompositionTarget.Rendering CompositionTarget.Rendering CompositionTarget.Rendering Event

Definition

Occurs when the core rendering process renders a frame.

public : event EventHandler<Platform::Object> Rendering
// Register
event_token Rendering(EventHandler<Platform::Object> const& handler) const;

// Revoke with event_token
void Rendering(event_token const& cookie) const;

// Revoke with event_revoker
Rendering_revoker Rendering(auto_revoke_t, EventHandler<Platform::Object> const& handler) const;
public event EventHandler<object> Rendering
Public Event Rendering As EventHandler (Of object)

Remarks

Handling Rendering can be useful if you have interop scenarios with Microsoft DirectX content. For example you might want to know when the XAML framework is rendering a frame and synchronize that with your Microsoft DirectX generated content in a SwapChainPanel or SurfaceImageSource so visual updates are presented to the screen at the same time. For more info, see DirectX and XAML interop.

To satisfy the compiler, the second e/args parameter of your handler for a Rendering event must be Object. Don't use EventArgs. However, within the handler, you can cast the e/args reference as RenderingEventArgs. RenderingEventArgs has one property, RenderingTime, that might be useful in your rendering scenario, but not all handlers would need this info. It may be enough just to know that the event fires and handle every occurrence.

Handlers for Rendering run on the UI thread even though they're not tied to any specific UI element. This is similar to running an infinite animation. Normally the UI thread is active only when there is work to do, but adding a handler for this event forces it to run every frame which can prevent system power usage optimizations. It's therefore a good idea to remove any Rendering handlers when you no longer need them, and add them only when you do need them. For example add the handler only when specific pages with synchronized DirectX content are loaded, and then remove the handler as part of page cleanup (OnNavigatedFrom ). For more information see the Use infinite animations sparingly section of the performance guide.

See also