![]() ![]() Sadly, the Delphi examples and, I'm afraid, many textbooks, dont' get much further than suspend/resume control of threads, (don't do it), and 'TThread.Synchronize', 'TThread.WaitFor' and 'TThread.OnTerminate'. When doing something like this, I oftem just leave the threads lying around even if I don't need to process any more URI during the app run - it's not worth the typing of terminating them. Terminate the threads? Sure, if you really have to, then queue up some object that signals them to commit suicide, (a NIL maybe - the threads can check for 'assigned' just after popping the queue). ![]() If you wish to notify the main thread, PostMessage the completed URI's and free them in the message-handler. You do not say what action you need taking with the processed TURI's - they will need freeing somewhere. Hang a few TThreads off the queue that loop around and process the TURI instances until the queue is empty, whereupon they block. Create, initialize 100 of these and push them on a producer-consumer queue, (TObjectQueue, TCriticalSection and a semaphore should do fine). Define a 'TURI' class for the request URI, result, error message and anything else needed for the web query except for the component to be used for the URI access.
0 Comments
Leave a Reply. |