Hello,
Recently, I found in this thread:
https://en.delphipraxis.net/topic/1010-using-indy-for-cross-platform-tcpip/ that calling TIdTCPClient.IOHandler.Write... (which is something that I've been doing since forever - thanks to almost every tutorial - and that seems to work fine) from main thread can be "unsafe" and it's not recommended.
However, I cannot call it from the thread I have already created and used for listening (TIdTCPClient.IOHandler.Read...), since this thread is usually blocked waiting for incoming messages. Do I need a third thread then? Or can I use same thread, sequentially reading with some small timeout (but how small can it be), and writing from queue?
I basically want to create a TCPClient wrapper that has Connect, Disconnect, WriteLn methods, some OnReadLn event and Connected property all working with main (UI) thread, in an asynchronous, non-blocking way. Are somewhere examples how to do it in the most simple and "right" way?
Best regards