Is there a performance difference between WPF and Winforms?

后端 未结 4 1574
春和景丽
春和景丽 2021-02-01 20:02

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

4条回答
  •  北荒
    北荒 (楼主)
    2021-02-01 20:31

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

    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.

    2. How effectively you optimize for performance on each platform.

      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.

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

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

    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.

    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.


    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.

提交回复
热议问题