WPF Databinding thread safety?

后端 未结 3 577
忘掉有多难
忘掉有多难 2020-11-29 04:39

Well lets say i have an object that i databind to, it implements INotifyPropertyChanged to tell the GUI when a value has changed...

if i trigger this from a differen

3条回答
  •  遥遥无期
    2020-11-29 05:19

    In addition to @Rob Fonseca-Ensor's answer, there is some good news for those lucky enough to use WPF4.5:

    WPF enables you to access and modify data collections on threads other than the one that created the collection. This enables you to use a background thread to receive data from an external source, such as a database, and display the data on the UI thread. By using another thread to modify the collection, your user interface remains responsive to user interaction. (https://msdn.microsoft.com/en-us/library/bb613588(v=vs.110).aspx#xthread_access)

    There's a helpful summary by Jonathan Antoine: http://www.jonathanantoine.com/2011/09/24/wpf-4-5-part-7-accessing-collections-on-non-ui-threads/

提交回复
热议问题