// Thread 2 START Thread 2 START Thread 2 START Thread 2 START
type
Thread_Nr_02 =
class(TThread)
procedure Hauptprogramm;
procedure Execute;
override;
end;
procedure Thread_Nr_02.Execute;
begin
while not Terminated
do begin
Synchronize(Hauptprogramm);
end;
end;
procedure Thread_Nr_02.Hauptprogramm;
var
data: TIdMultiPartFormDataStream;
dieurl :
string;
A: TStrArray;
AnzTokens, i, ccc, ccc2: Integer;
csv: TStringList;
begin
Screen.Cursor := crHourGlass;
data := TIdMultiPartFormDataStream.Create;
dieurl := Form1.Edit1.Text;
try
data.AddFormField('
id', '
1');
Form1.Memo1.Text := Form1.IdHTTP1.Post(dieurl, data);
Form1.Memo1.Lines.SaveToFile('
shops.txt');
finally
data.Free;
end;
ccc := -1;
if FileExists('
shops.txt')
then begin
csv := TStringList.Create;
csv.LoadFromFile('
shops.txt');
Form1.StringGrid1.Rowcount :=
csv.Count;
for ccc2 :=
csv.Count - 1
downto 1
do begin
AnzTokens := Explode(A, '
;',
csv.Strings[ccc2]);
for i := 0
to AnzTokens -1
do begin
ccc := ccc + 1;
if ccc < 6
then begin Form1.StringGrid1.Cells[ccc, ccc2] := A[i];
end;
if ccc = 6
then begin ccc := -1;
end;
end;
end;
end;
Screen.Cursor := crDefault;
Terminate;
end;
procedure TForm1.Button1Click(Sender: TObject);
var Th: Thread_Nr_02;
begin
Th := Thread_Nr_02.Create(True);
// Thread erzeugen (suspended)
Th.FreeOnTerminate := True;
// Thread gibt sich selbst frei
Th.Resume;
// Thread starten
end;