3

I am to evaluate several competing frameworks for WPF components which process large amounts of data (100000 entries and up). Thus, I need to time the real performance. As all our software is strictly MVVM/Data binding driven, that is the test environment I use. What I need is to find a way to measure time between my view model sets some value and the end of rendering by the view. Visually it takes several seconds, but I'd like to have exact measurements.

I can of course start a stopwatch when setting the property, but how do I find out that the rendering is ready? Is there an event or something for this?

4

1 回答 1

8

也许它不会给你确切的措施,但一个简单的方法是使用 Dispatcher

var sw = new StopWatch();
sw.Start();
//Set value and raise property changed
Dispatcher.CurrentDispatcher.BeginInvoke((Action)(() =>
{
   sw.Stop();

}), System.Windows.Threading.DispatcherPriority.Loaded);

Loaded 优先级略低于 Render 优先级,因此秒表将在视图渲染后停止。

于 2012-12-17T10:53:53.190 回答