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

WPF+ MVVM: How to Make the WPF Application More Responsive ?

$
0
0

I have been asked a question:  There is big data need to be updated in UI and the big data updating will take a while and the same time users try to type in text in textbox. How to you ensure that user input have the highest priority over big data field update?

In code behind, one of solution would be using Dispatcher with a specific priority: Dispatcher.BeginInvoke Method (DispatcherPriority, Delegate, Object, Object[]) (async call)

Dispatcher.Invoke Method (DispatcherPriority, Delegate, Object) (sync call)

This allows for both ordering of items by priority and deferring certain types of work until the system has time to handle them. (For example, some work items can be deferred until the system or application is idle). Reference the article:

Build More Responsive Apps With The Dispatcher
Shawn Wildermuth

http://msdn.microsoft.com/en-us/magazine/cc163328.aspx

In this article, it mentions that "Unlike a typical message pump implementation, the Dispatcher is a priority-based queue of work items. This allows for better responsiveness because the more important pieces of work are executed before less important pieces of work."

In WPF and MVVM design pattern, I wonder how do we achieve that goal? When VM get "BigDataPropertyName" update info, it will not call OnPropertyChanged ("BigDataPropertyName") right way. It will wait until UI is idle and callOnPropertyChanged ("BigDataPropertyName"). However, since the VM does not know about UI status, how VM detect UI is idle or there is total different way to achieve it?

Does anyone know to how handlethis case in MVVM? Thx!


JaneC




Viewing all articles
Browse latest Browse all 18858

Trending Articles



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