1

我正在使用 IdTCPServer 并且它在有限的时间内运行良好,我担心它与列表视图中的线程管理有关,因为我使用 TTimer 来处理数据 atm。所以我想知道我可以处理这些连接以进行读写的可能方法,服务器将处理许多连接(实时接收、处理和发送数据)。

4

1 回答 1

1

TIdTCPServer is a multi-threaded component. Any access to the UI must be synchronized with the main UI thread, such as with Indy's TIdSync or TIdNotify classes, or bad things can happen. A TTimer in the main thread is an OK choice for accessing data, provided the data is being accessed in a thread-safe manner, such as with a mutex or critical section. But a timer is not necessarily the best choice. It really depends on what your code actually needs to do with the data and the UI. Without that information, it is hard to advise you what is the best approach to meet your needs. There are many choices available.

于 2012-06-18T02:31:00.183 回答