INDY 10 TCP服务器 - 结合非线程安全的VCL代码 [英] INDY 10 TCP Server - Combine with non thread safe VCL Code
问题描述
server.execute(...)
函数中向gui写入信息不是一个好主意。 如何将信息从服务器执行发送到VCL?
我需要修改 tcpserver中的TBitmap .execute
函数。如何使线程安全?
从Indy向VCL线程写入东西,以相同的方式将东西写入VCL线程从其他任何地方。常见的选项包括 TThread.Synchronize
和 TThread.Queue
。
修改独立的 TBitmap
不应该要求主线程序列化。您可以从任何想要的线程修改它,只要您一次只从一个线程执行。您可以使用标准同步对象(如关键部分和事件)来确保一次只能使用一个线程。
VCL is not thread safe. Therefore I guess it is not a good idea to write information to the gui in the INDY 10 TCP server.execute(...)
function .
How to send information from the server execute to the VCL ?
I need to modify a TBitmap inside a tcpserver.execute
function. How to make that thread safe ?
Write stuff to the VCL thread from Indy the same way to write stuff to the VCL thread from anywhere else. Common options include TThread.Synchronize
and TThread.Queue
.
Modifying a standalone TBitmap
should not require serialization with the main thread. You can modify it from any thread you want, as long as you do it from only one thread at a time. You can use the standard synchronization objects like critical sections and events to make sure only one thread uses it at a time.
这篇关于INDY 10 TCP服务器 - 结合非线程安全的VCL代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!