5

私はインディ TIdHttp をスレッドに入れようとしています、私はこれを試しました:

type
  TSendThread = class(TThread)
  private
    { Private declarations }
  protected
    procedure Execute; override;
  public
    http : TIdHTTP;
    URL : String;
    Method : String;
    property ReturnValue;
  end;

procedure TSendThread.Execute;
begin
  form1.Memo1.lines.Add(http.Get(URL));
  ReturnValue := 1;
end;

そして主に:

procedure TForm1.Button1Click(Sender: TObject);
var t : TSendThread;
begin
  t := TSendThread.Create(true);
  t.URL := 'http://www.url.com/';
  t.http := http;
  t.Start;
  showmessage(IntToStr(t.ReturnValue));
end;

ここでの問題は、スレッドが完了するのを待たずに次の命令が実行される (showmessage) ことです。「WaitFor」を使用しようとしましたが、アプリケーションがフリーズします。

他の回避策はありますか?

ありがとうございました。

4

1 に答える 1