WPF 转换器是如何执行的?
我在非常复杂的 WPF UI 中面临渲染问题,其中包含大量转换器(IValueConverter、IMultiValueConverter)。
我想知道转换器是否可以参与其中。
有谁知道 WPF 转换器是如何工作的? 它们是并行执行然后与 UI 线程同步吗?或者是否有某种 foreach 循环可以处理每个转换器?
I'm facing render issues in very complex WPF UI which contains, among other things, a lot of Converters (IValueConverter, IMultiValueConverter).
I would like to know if the converters could be involved into this.
Does anyone known how WPF Converters worked ?
Are they executed in parallel and then synchronized with the UI thread ? or is there some kind of foreach loop that treat every converter ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
转换器在 UI 线程上执行,您可以使用 Thread.Sleep(10000) 之类的方法阻塞线程来测试这一点。 UI 在调度程序队列中进行管理,请参阅线程模型参考了解详细信息,更新为绑定被推入该队列。如果更新了绑定,则会调用转换器,通常不会同时调用它们。
(另请参阅下面的好评)
The converters are executed on the UI-thread, you can test this by blocking the thread using something like
Thread.Sleep(10000)
. The UI is managed in a dispatcher queue, see the threading model reference for more information, updates to bindings are pushed into that queue. Converters are called if the binding was updated, they normally are not being called at the same time.(Also see the good comments below)