• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

C#的WinForms和一种或多种额外的线程制图。怎么样

用户头像
it1352
帮助1

问题说明

在情况下,我有各种几何形状(直线,矩形,圆形,e.t.c.)大的绘图需要花费大量的时间线绘制的一切。但在现实生活中,一个建筑物是由一个以上的工人建造的。因此,如果图纸是建设和线程的建设者,它会拿得出速度快了很多。但我想知道怎么办。

In case I have a big drawing with all kinds of geometric forms (lines, rectangles, circles, e.t.c.) it takes a lot of time for the thread to draw everything. But in real life, one building is built by more than one workers. So if the drawing is the building and the threads are the builders, it will get drawn a lot faster. But I want to know how.

你能告诉我怎么样?它甚至有可能(虽然我已经问,答案是是)?是否值得使用?什么是风险?

Can you tell me how? Is it even possible (though I have already asked and the answer was "Yes")? Is it worth it to be used? What are the risks?

如果有,我已经错过了问题,请告诉我他们并回答他们。

If there are questions that I have missed, please tell me about them and answer them.

谢谢!

正确答案

#1

假设你正在使用GDI 和 System.Drawing.Graphics 对象来渲染图形(矩形,圆等),背景绘制的表面(如 System.Drawing.Bitmap 对象)的实例成员 System.Drawing.Graphics 对象,您将需要使用的不是线程安全即可。 参见MSDN文档这里

Assuming you are using GDI and the System.Drawing.Graphics object to render your graphics (rectangles, circles, etc.) to a background drawing surface (e.g. System.Drawing.Bitmap Object): Instance members of the System.Drawing.Graphics object that you would need to use are not thread safe. See MSDN documentation here

鉴于此,我不会使用超过一个建设者线程多来渲染图形。

Given this, I would not use more than one "builder" thread to render your graphics.

相反,我的建议是做所有绘图到 System.Drawing.Bitmap 对象在一个后台线程,而不是多线程后台如果可能的话。您可以使用一个状态栏或其他指示,让用户知道你的程序在后台运行。

Instead, my recommendation would be to do all of your drawing to a System.Drawing.Bitmap object in a single background thread rather than multiple background threads if possible. You can use a status bar or other indicator to let the user know that your program is working in the background.

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /reply/detail/tanhceahhg
系列文章
更多 icon
同类精品
更多 icon
继续加载