异步线程位图绘制德尔福 [英] Asynchronous threads drawing in Bitmaps Delphi

查看:142
本文介绍了异步线程位图绘制德尔福的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果许多异步线程在全球TBitmap画,它会涨我一个错误?我要创造我的code。使用一个关键部分? (从我在互联网上冲浪我发现TBitmap.Draw不是线程安全的)

If many asynchronous threads draw in a global TBitmap, it will rise me an error? Should I create my code using a critical section? (From my surf on the internet I found that the TBitmap.Draw is not thread safe)

另外一个问题:如果许多线程同步在全球TBitmap画和VCL定时器异步读取来自TBitmap内容将在上升我一个错误

Another question: If many synchronous threads draw in a global TBitmap and a VCL Timer read asynchronously the content from the TBitmap will this rise me an error?

谢谢!

推荐答案

由于您的线程都修改相同的位图,你需要序列化所有访问该位图。这意味着,读取它的内容,以及写它。

Since your threads are all modifying the same bitmap, you need to serialize all access to that bitmap. That means reading its contents as well as writing to it.

当然,这个假设多个线程绘图到一个共享的位图是你的问题的解决方案。不知道你的实际问题是什么,我不能对此作出评论。

Of course, this assumes that multiple threads drawing to a shared bitmap is the right solution to your problem. Without knowing what your actual problem is, I could not comment on that.

这篇关于异步线程位图绘制德尔福的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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