ihttp多线程问题,各位高手帮忙啊(200分)

  • 主题发起人 主题发起人 PROSE
  • 开始时间 开始时间
P

PROSE

Unregistered / Unconfirmed
GUEST, unregistred user!
type 部分
TMMThread =class(TThread)
tthreadid:integer;
tthreadtype:integer;
urlStr :String;
ttpostdata :TStrings;
ttresponses : TStringStream;
constructor Create(ttid:integer;typeflag:integer;url:String;postdate:TStrings;responses : TStringStream);
procedure Execute;
override;
end;

{ TMMThread }
constructor TMMThread.create(ttid:integer;typeflag:integer;url:String;postdate:TStrings;responses : TStringStream);
begin
inherited Create(True);
FreeOnTerminate:=True;
Suspended:=false;
tthreadid:=ttid;
tthreadtype:=typeflag;
urlStr :=url;
ttpostdata :=postdate;
ttresponses := responses;
end;
procedure TMMThread.Execute;
var
thIdHTTP: TIdHTTP;
begin
try
thIdHTTP := TIdHTTP.Create(nil);
if tthreadtype =1 then
begin
thIdHTTP.HandleRedirects := True;
thIdHTTP.Request.ContentType := 'application/x-www-form-urlencoded' ;
thIdHTTP.Post(urlStr,ttpostdata,ttresponses);
end
else
if tthreadtype =2 then
begin
thIdHTTP.get(urlStr,ttresponses);
end;
finally
thIdHTTP.free;
end;

end;

var
Responses : TStringStream ;
PostData: TStrings;
surl,tt :string;
addThread :TMMThread;
调用部分
surl := 'http://'+serverurl+'/game/reg/login2.php';
addThread:=TMMThread.Create(1,1,surl,PostData, Responses);
可是
thIdHTTP.Post(urlStr,ttpostdata,ttresponses);
执行异常!!
哪位高手帮忙看看啊
 
ttresponses改为TMemoryStream试试
 
FreeOnTerminate:=True;
Suspended:=false;
tthreadid:=ttid;
tthreadtype:=typeflag;
urlStr :=url;
ttpostdata :=postdate;
ttresponses := responses;
inherited Create(True);//这句放后面
 
放后边好像不执行
 
后退
顶部