I do not know about the "best" - it depends on your criteria. If you change your requirements a bit, we can offer more specific assistance. Meanwhile...
The easiest way is to allow your own object to write the request to the stream, either into one or more properties, or by the public method. The data fields behind the properties / method are not directly processed by the main Execute procedure: use a method called Synchronize () to copy these data fields into variables that can be used in the Execute () procedure. I use this method when speed is not the main goal, and for the owner object it is not necessary to queue several requests.
Many people humiliate the use of Synchronize, but it depends on what functionality you are trying to achieve. I try to keep things simple until requirements require otherwise.
If bandwidth is a bigger issue or you need overlapping requests, you can use the queue to store requests with access to the queue controlled by TCriticalSection. You can also use TThreadList, either directly or as the basis for your own typed repository - I don't know about the general equivalent of TThreadList, although it may be.
source share