WPF数据绑定线程安全? [英] WPF Databinding thread safety?
问题描述
如果我触发这个与GUI线程不同的线程如何wpf的行为?
,它会确保它从内存中获取属性的值,而不是cpu缓存? p>
或多或少im询问是否wpf在包含属性的对象上执行lock()...
INotifyPropertyChanged
触发的值更改会自动编组回到调度程序。 ( http://blog.lab49.com/archives/1166 )
在任何您喜欢的线程上触发此事件
INotifyCollectionChanged
不可靠地编组到调度程序。 ( http:// csharplive如果你需要的话,那么你可以使用这个方法来实现这个功能。从不同的线程更新可观察的集合,请遵循此链接中的建议
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 different thread than the GUI thread how would wpf behave?
and will it make sure that it gets the value of the property from memory and not the cpu cache?
more or less im asking if wpf does lock() on the object containing the property...
Value changes fired by INotifyPropertyChanged
are automatically marshalled back onto the dispatcher. (http://blog.lab49.com/archives/1166)
Fire this event on any thread you like...
Value changes fired by INotifyCollectionChanged
are NOT reliably marshalled onto the dispatcher. (http://csharplive.wordpress.com/2008/09/11/wpf-data-binding-observablecollection-cross-thread-binding-support/)
If you need to update an observable collection from a different thread, follow the advice in this link
这篇关于WPF数据绑定线程安全?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!