WPF 线程、后台工作者、调度程序
我是wpf线程的新手,现在我们有了backgroundworker和dispatcher类,经典的winforms线程问题不再是问题了?
I am new to wpf threading, now that we have backgroundworker and dispatcher classes, classic winforms threading issues are no longer a problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您仍然可能会遇到所有这些问题。 WPF 并没有神奇地解决任何线程问题。 它只是为您提供了更多可用的工具。 BackgroundWorker 已经存在了一段时间,虽然很有用,但它仍然有可能出现死锁、竞争条件等。线程问题的最佳解决方法是一如既往地仔细开发和小心调试。
You can still have all of these problems. WPF hasn't magically solved any threading issue. It just gives you a couple more tools to use. BackgroundWorker has been around for a while, and although useful, it is still just as possible to get deadlocks, race conditions, etc. The best cure for threading issues, is, as always, careful development and careful debugging.
我在专业情况下拥有丰富的线程经验,包括相当多的 WPF 经验,但我可以告诉您,它并不能解决任何这些问题。
它比 winform 更好,因为 Dispatcher 可以让您更清楚地了解线程模型是什么,但仅此而已。
即使他们愿意,它实际上也不能做更多的事情。 线程本质上是一件复杂而丑陋的事情,你不能仅仅通过几个 GUI 库就神奇地让它消失
I have plenty of hands on threading experience in a professional situation, including quite a bit with WPF, and I can tell you that it does not solve any of these problems.
It is nicer than winforms in that the Dispatcher gives you a more clear idea of what the threading model is, but it doesn't go much further than that.
There isn't really much more that it could do even if they wanted to. Threading is an inherently complicated and ugly thing, and you can't just magically make it go away with a few GUI libraries