WPF 和 Winforms 之间有性能差异吗? [英] Is there a performance difference between WPF and Winforms?

查看:30
本文介绍了WPF 和 Winforms 之间有性能差异吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

标题几乎说明了一切.我做了一些谷歌搜索,但我能找到的唯一信息至少是一年前的,有些信息比 Windows 7 还要早.所以我很好奇,使用 WPF 会不会有性能损失?

The title pretty much says it all. I did some Googling, but the only information I can find is at least a year old, some of the info is older than Windows 7. So I'm curious, is there a performance penalty for using WPF?

它在某些方面(例如数据绑定)的工作速度是否比您必须在 WinForms 上一起破解的速度更快?

Does it work faster for somethings (such as data binding) than what you'd have to hack together on WinForms?

这将是一个使用 .NET 创建的项目,以防对任何人都很重要.

This will be a project created with .NET, in case that matters to anyone.

编辑

我正在查看的这个项目将具有基本的 UI 样式,但是可能会显示大量信息(它正在查询文件/目录并将它们显示在屏幕上).我还没有决定它是否会自动刷新屏幕,但我想可能会.

This project I'm looking at would have a basic style of UI, however there could be a lot of information displayed (it's querying files/directories and displaying them on the screen). I have not decided if it will auto-refresh the screen, but I imagine it may.

可能会有相当数量的控制,但没有任何人应该考虑图形"密集.

There will likely be a fair amount of controls, however nothing that anyone should consider "graphic" intensive.

我正在从业务应用程序的角度来看性能.

I'm looking at performance then from a business application perspective.

我不打算使用第 3 方控件.

I do NOT plan to use 3rd party controls.

推荐答案

对此没有有意义的是"或否"答案.这取决于许多因素,包括但肯定不限于:

There is no meaningful "yes" or "no" answer to this. It depends on many factors, including but certainly not limited to:

  1. 你正在构建什么样的用户界面.

  1. What kind of UI you are building.

显然,您正在设计的视图的复杂性将影响两个平台上的性能.它们具有不同的布局和渲染管道.

Obviously, the complexity of the views you are designing will factor in to performance on both platforms. They have different layout and rendering pipelines.

您在每个平台上优化性能的效率如何.

How effectively you optimize for performance on each platform.

当然,很容易在两个平台上实现性能不佳的 UI.实现一个复杂的用户界面以使其性能非常好,需要知道如何有效地利用每个平台的优势和劣势.

It is, of course, easy to implement poorly performing UIs with both platforms. Implementing a complex UI such that it performs very well requires knowing how to leverage each platform's strengths and weaknesses effectively.

您使用的是现成控件还是第三方控件,以及这些控件的质量.

Whether you are using out-of-the-box controls or third-party controls, and the quality of those controls.

第 1 项和第 2 项也适用于任何第三方组件.

Items 1 and 2 carry over to any third-party components as well.

如果您是一位经验丰富且能干的 WinForms 开发人员,那么您可能已经知道如何在 WinForms 中创建高性能视图.WPF 的学习曲线很陡峭;任何经验丰富的 WPF 开发人员都可以告诉您这一点.他们还会告诉您,您可以使用它来构建性能良好的丰富 UI.这也是事实.WinForms 也是如此.

If you are an experienced and competent WinForms developer, then you probably already know how to create performant views in WinForms. The learning curve for WPF is steep; any seasoned WPF developer can tell you that. They will also tell you that you can use it to build rich UIs that perform well. That is also true. The same is true for WinForms.

两个平台都很成熟.两者都被广泛使用.除了错误修复之外,两者都不太可能在未来看到任何改进.

Both platforms are mature. Both are used widely. Neither is likely to see any future improvements apart from bug fixes.

综上所述,如果您还没有对这两个平台进行大量投资,我会选择 WPF 路线.它是一个丰富的(尽管重量级)框架,可以使其表现良好.使其表现良好所需的工作量很大程度上取决于您创建的视图类型,但我已经使用 WPF 构建了许多高容量、高频数据视图.我还用 WPF 构建了一个视觉丰富的策略游戏.但是不要觉得被迫接受它;如果您的开发人员已经熟悉 WinForms,它仍然是一个非常可行的选择.

All that said, if you are not already heavily invested in either platform, I would go the WPF route. It's a rich (albeit heavyweight) framework that can be made to perform well. The amount of effort required to make it perform well depends largely on the types of views you are creating, but I have built many high volume, high frequency data views with WPF. I have also built a visually rich strategy game with WPF. But don't feel compelled to go with it; if your developers are already experienced with WinForms, it remains a perfectly viable option.

更新:我认为在未来几年内不太可能从 .NET 中删除 WinForms 支持,但如果这是一个问题,那么我会选择 WPF.您描述的视图类型可以很容易地在 WPF 中创建.为了比较,我有几个视图能够显示 50,000 到 500,000 行和 60 多列;每秒数千行更新;应用自定义、多级排序和分组;自定义过滤;自定义摘要;所有都以伪实时(人类"实时)保持最新状态.获得这种性能水平并不容易,但可以做到.使用任一平台并仅使用内置控制套件,您所描述的数据量和频率应该更容易实现.

Update: I think it is unlikely that WinForms support will be removed from .NET in the next few years, but if this is a concern, then I would go for WPF. The types of views you describe can be created in WPF easily enough. For comparison, I have several views capable of displaying 50,000 to 500,000 rows with 60+ columns; thousands of row updates per second; custom, multi-level sorting and grouping applied; custom filtering; custom summaries; all kept up to date in pseudo real time ("human" real time). Getting that level of performance was not easy, but it can be done. The volume and frequency of data you are describing should be considerably easier to achieve with either platform, and using only the built-in control suite.

这篇关于WPF 和 Winforms 之间有性能差异吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆