So?
Delphi-Quellcode:
TWorkThread = class(TThread);
procedure Execute; override;
end;
procedure TWorkThread.Execute;
begin
DoSomeGreatWork;
end;
procedure TMyClass.GetData;
var
Threads: TList<TThread>;
i: integer;
procedure ReceiveData;
var
Response: IResponse;
Thread: TWorkThread;
begin
Response := GetDataFromServer;
Thread := TWorkThread.Create;
Thread.Resume;
Threads.Add(Thread);
MoreData := Response.HasMoreData;
end;
begin
Threads := TList<TThread>.Create;
repeat
ReceiveData;
until not MoreData;
// Wait for threads to finish
for i := 0 to Threads.Count - 1 do
begin
Threads[i].WaitFor;
Threads[i].Free;
end;
// Do further work
...
Threads.Free;
end;
(Keine Ahnung, ob ich die Generics richtig verwendet habe)