Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Is WPF throttling data bound property changes on worker threads?

$
0
0

I tried to stress-test some things and I created an MVVM application that updates a data-bound view model property of type decimal something like 180,000 times a second. To my astonishment, the application still ran successfully, taking approximately 36% CPU on my machine.

Very approximately it looked like this:

// C#
class ViewModel : INotifyPropertyChanged
{	
     private decimal _foo;
     public decimal Foo 
     {
         get { return _foo; }
         set { _foo = value; RaisePropetryChanged("Foo"); 
     }

     void OnTick()
     {
         // called on a worker thread in a busy loop
         Foo = some_random_value;
     }
}

The XAML looks approximately like this:

<DataGrid ItemsSource="{Binding ArrayOfViewModels}" />

If I manually use Dispatcher.BeginInvoke in the OnTick() handler, the application grinds to a halt, just like I expected and then fails with OutOfMemory exception.

It looks like WPF is doing some throttling on my behalf here. Is it something new in version 4.5? Is it documented? I am using Visual Studio 2012 and .NET Framework 4.5.



Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>