How to measure screen render time in WPF

Brian Erickson picture Brian Erickson · Mar 31, 2011 · Viewed 7.5k times · Source

I am attempting to measure the performance for a WPF based application. Currently we have code that times how long it takes to add the content to the WPF render tree. At this point, control is returned to our program. The problem is that there is still a lag before content is displayed on the screen by WPF. For complicated rendering trees, this can be a matter of seconds.

Can you recommend a method to determine when WPF has completed rendering to the screen? I would like these tests to be fully automated and not rely on someone sitting around with a stopwatch.

[update]

Thanks for the suggestions so far.

I have tried waiting for the Loaded and ContentRendered events, but both fire before the content makes it to the screen.

It looks like others are having this issue. I have tried the steps suggested at http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/693fbedb-efa6-413e-ab66-530c6961d3fb/ but still haven't been able force my code to wait for the rendering to complete.