I use Indy's TIdTCPServer (D2009, Indy 10) to communicate with client applications. In the OnExecute method I create a task and queue it. A worker thread executes the task and puts it in the send queue. The send queue then sends the response to the client.
In the send thread I loop through the server's context list and look for the context matching the IP and port information stored in the task. Then follow a number of send commands that sometimes throw access violations (I'm guessing that the context gets destroyed during sending).
Now to the question: how can I make sure that the context is not closed before I have sent the response? Is it possible with Indy to send from a separate thread or should everything be done in the Indy thread?