i'm using AnonymousThreads and StringList to do http request behind a proxy server. i'm using the list to hold the proxies, i choose randomly a proxy from the list and use it. i keep adding strings to the list. after a while the threads stops, i'm creating the ssl and http components in for loop. i think the problem is caused by accessing the list from multiple threads. i tried using Pipleline threads from Omni Treads library. it greate. but its slow with proxies because it's creating task after another but not at the same time.. i need a simple alternative to StringList where i can access the list without causing the threads to stop.
Procedure GetData;
....
var
list : TStrings;
....
for i := 0 to 10 do
begin
GetData;
end;
TForm1.GetData;
var
x1, x2 : Integer;
G1 : String;
begin
try
X1 := list.count
X2 := RansomRange(0, X1);
G1 := list.strings[X2];
list.Delete(X2);
lHTTP := TIdHTTP.Create(nil);
IdSSL := TIdSSLIOHandlerSocketOpenSSL.Create(lHTTP);
....
idssl.free;
lhttpfree;
except on E: EIdHTTPProtocolException do
begin
idssl.free;
lhttpfree;
list.add(X2);
TThread.Synchronize (TThread.CurrentThread,
procedure ()
begin
memo1.lines.add(E.ErrorMessage);
end);
end;
end;
end;