You are using a windowed control (TPanel
) for your content. The more instances you create, the more OS resources are allocated and managed, and the slower things get over time. To avoid all of that overhead, use a graphical control instead, such as TLabel
or even create your own component derived from TGraphicControl
.
Alternatively, you can switch to a different windowed control that is designed for displaying lots of data, such as a TListView
or TListBox
running in virtual mode. Then you don't need the TScrollBox
anymore.
BTW, the TIdThreadComponent.OnRun
event handler runs in the context of a worker thread, not the main thread. The code you showed is not thread-safe. The TPanel
code needs to be executed in the context of the main thread via TThread.Synchronize()
, TIdSync
, or any other inter-thread synchronization mechanism. In which case, the TIdThreadComponent
code you showed becomes useless as a thread and could be replaced with a simple timer or custom window message instead.