有关使用调度员优先级和绑定的建议
在我的应用程序中,我使用 UI 线程的空闲时间来卸载昂贵的操作,如 有关 WPF 线程模型的 MSDN 文章。
GenerateDataAction = () => { GenerateData(); };
Dispatcher.BeginInvoke(GenerateDataAction, DispatcherPriority.Render, null);
在 GenerateDate()
方法中,我访问 MSSQL 数据库、处理数据并更新视图模型上的绑定。自从实现此功能以来,我注意到一些绑定无法正确更新或根本无法更新。我已经检查了输出中是否存在绑定错误,并让第二个程序员确认了逻辑,还在依赖属性更改方法中设置了断点(断点不会被击中)。
是否有关于 which DispatcherPriority
的最佳实践建议(MSDN 链接)?
In my application I'm using the idle-time of the UI thread to offload expensive operations as described by MSDN article on the WPF Threading Model.
GenerateDataAction = () => { GenerateData(); };
Dispatcher.BeginInvoke(GenerateDataAction, DispatcherPriority.Render, null);
In the GenerateDate()
method I access an MSSQL database, process the data in, and update bindings on the viewmodel. I have noticed since implementing this that some binding fail to update properly or not at all. I have check the output for binding errors and had a second programmer confirm the logic, also have set breakpoints within the dependency property changed method (the breakpoints do not get hit).
Is there any best-practice advice on which DispatcherPriority
(link to MSDN) should be used when the invoked action contains bindings?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
关于 WPF 调度程序的一篇非常好的文章: http ://weblogs.asp.net/pawanmishra/archive/2010/06/06/understanding-dispatcher-in-wpf.aspx
A very good article about WPF dispatcher: http://weblogs.asp.net/pawanmishra/archive/2010/06/06/understanding-dispatcher-in-wpf.aspx