INDY 10 TCP服务器 - 结合非线程安全的VCL代码 [英] INDY 10 TCP Server - Combine with non thread safe VCL Code

查看:222
本文介绍了INDY 10 TCP服务器 - 结合非线程安全的VCL代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

VCL不是线程安全的。因此,我想在INDY 10 TCP 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屋!

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