Search code examples
indyindy10delphi

INDY 10 TCP Server - Combine with non thread safe VCL Code


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 ?


Solution

  • 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 synchronization 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.