如何提高Mono中winforms应用程序的性能?

时间:2021-10-31 06:35:51

I have a remoting application (2 player Magic the Gathering Game) using windows form in C# and I am seeing very poor performance in mono. One thing I can think of that might affect the performance is that I have custom images for button background and form backgrounds(.png). Moreover I heavily use card images (.jpg). Lastly I have stuck very strictly to .NET 2.0.

我有一个远程应用程序(2人Magic the Gathering Game)在C#中使用Windows窗体,我看到单声道的性能非常差。我能想到的一件可能会影响性能的是我有按钮背景和表单背景(.png)的自定义图像。此外,我大量使用卡片图像(.jpg)。最后我非常严格地坚持使用.NET 2.0。

What can I look for to improve windows Form performance in mono? If this is not possible is there a quick winforms to gtk# converter or tool that helps in converting?

我可以找到什么来改善单声道的窗体性能?如果这是不可能的,有一个快速winforms到gtk#转换器或工具,有助于转换?

3 个解决方案

#1


Did you try to profile your code. Maybe that shows you where the bottlenecks are...

您是否尝试对代码进行了分析也许这会告诉你瓶颈在哪里......

I think one big problem is

我认为一个大问题是

Whereas the .Net implementation is a binding to the Win32 toolkit, the Mono implementation is written in C# to allow it to work on multiple platforms

虽然.Net实现是对Win32工具包的绑定,但Mono实现是用C#编写的,以允许它在多个平台上工作

as mentioned here and

正如这里提到的那样

System.Windows.Forms in Mono is implemented using System.Drawing. All controls are natively drawn through System.Drawing. System.Windows.Forms implements its own driver interface to communicate with the host OS windowing system.

Mono中的System.Windows.Forms是使用System.Drawing实现的。所有控件都是通过System.Drawing本地绘制的。 System.Windows.Forms实现自己的驱动程序接口,以与主机OS窗口系统进行通信。

as described here.

如此处所述。

I don't know of a converter from winforms to gtk#..., but if you really want to bother with converting your game to gtk#, this might be a good starting point.

我不知道从winforms转换为gtk#...,但是如果你真的想把你的游戏转换为gtk#,这可能是一个很好的起点。

#2


It would be useful if you could detail exactly what the performance problems are that you are observing.

如果您可以准确详细说明您正在观察的性能问题,那将非常有用。

Mono's Windows.Forms implementation is a bit slower today due to some of the requirements imposed by trying to support the WndProc model embedded into it properly.

由于尝试支持正确嵌入其中的WndProc模型所带来的一些要求,Mono的Windows.Forms实现今天有点慢。

It is an area that could be improved and likely many of the lessons from Wine could be applied to Mono's Winforms implementation.

这是一个可以改进的领域,很可能Wine的许多课程都可以应用于Mono的Winforms实现。

#3


Have you tried profiling it? Mono has a built-in profiler. There's a page on the mono website about the mono profiler and other performance tips.

你尝试过分析它吗? Mono有一个内置的分析器。单声道网站上有关于mono profiler和其他性能提示的页面。

#1


Did you try to profile your code. Maybe that shows you where the bottlenecks are...

您是否尝试对代码进行了分析也许这会告诉你瓶颈在哪里......

I think one big problem is

我认为一个大问题是

Whereas the .Net implementation is a binding to the Win32 toolkit, the Mono implementation is written in C# to allow it to work on multiple platforms

虽然.Net实现是对Win32工具包的绑定,但Mono实现是用C#编写的,以允许它在多个平台上工作

as mentioned here and

正如这里提到的那样

System.Windows.Forms in Mono is implemented using System.Drawing. All controls are natively drawn through System.Drawing. System.Windows.Forms implements its own driver interface to communicate with the host OS windowing system.

Mono中的System.Windows.Forms是使用System.Drawing实现的。所有控件都是通过System.Drawing本地绘制的。 System.Windows.Forms实现自己的驱动程序接口,以与主机OS窗口系统进行通信。

as described here.

如此处所述。

I don't know of a converter from winforms to gtk#..., but if you really want to bother with converting your game to gtk#, this might be a good starting point.

我不知道从winforms转换为gtk#...,但是如果你真的想把你的游戏转换为gtk#,这可能是一个很好的起点。

#2


It would be useful if you could detail exactly what the performance problems are that you are observing.

如果您可以准确详细说明您正在观察的性能问题,那将非常有用。

Mono's Windows.Forms implementation is a bit slower today due to some of the requirements imposed by trying to support the WndProc model embedded into it properly.

由于尝试支持正确嵌入其中的WndProc模型所带来的一些要求,Mono的Windows.Forms实现今天有点慢。

It is an area that could be improved and likely many of the lessons from Wine could be applied to Mono's Winforms implementation.

这是一个可以改进的领域,很可能Wine的许多课程都可以应用于Mono的Winforms实现。

#3


Have you tried profiling it? Mono has a built-in profiler. There's a page on the mono website about the mono profiler and other performance tips.

你尝试过分析它吗? Mono有一个内置的分析器。单声道网站上有关于mono profiler和其他性能提示的页面。