Updating bound properties from a background thread

后端 未结 3 565
滥情空心
滥情空心 2020-12-11 09:54

I have a WPF control that is bound to properties in my ViewModel. To my surprise (as this doesn\'t seem like a well-advertised feature of WPF), there seem to be no issues wi

3条回答
  •  一个人的身影
    2020-12-11 10:14

    WPF automatically ensures that bindings are updated on the main thread.

    There's no performance hit. If anything it's better to do the property updates on the background thread. Dispatching updates to the main thread would increase the amount of work being done there. You would be updating both the View and the ViewModel, rather than just the View. The difference should normally be negligible, but if a lot of updates are happening rapidly then it might cause the UI's responsiveness to degrade more quickly.

提交回复
热议问题