procedure TForm1.pp;
var
paralist:Tstringlist ;
s1:TStringStream ;
begin
paralist := Tstringlist.Create ;
s1 := TStringStream.Create('');
PARALIST.ADD('na=user') ;
PARALIST.ADD('pass=pass') ;
PARALIST.ADD('ac=edit') ;
PARALIST.ADD('id=54') ;
form1.IdHTTP1.Request.Referer := 'http://www.xxxxxxx.com/index.html' ;
try
idhttp1.Post('http://www.xxxxxxx.com/edit.asp', paralist, s1) ;
finally
paralist.Free ;
s1.Free ;
end;
end;哪位大哥帮我把这个过程,改为线程来执行呀?
var
paralist:Tstringlist ;
s1:TStringStream ;
begin
paralist := Tstringlist.Create ;
s1 := TStringStream.Create('');
PARALIST.ADD('na=user') ;
PARALIST.ADD('pass=pass') ;
PARALIST.ADD('ac=edit') ;
PARALIST.ADD('id=54') ;
form1.IdHTTP1.Request.Referer := 'http://www.xxxxxxx.com/index.html' ;
try
idhttp1.Post('http://www.xxxxxxx.com/edit.asp', paralist, s1) ;
finally
paralist.Free ;
s1.Free ;
end;
end;哪位大哥帮我把这个过程,改为线程来执行呀?
procedure run;///////
procedure run;
begin
form1.IdHTTP1.Request.Referer := 'http://www.xxxxxxx.com/index.html' ;
idhttp1.Post('http://www.xxxxxxx.com/edit.asp', paralist, s1) ;
end;
var
paralist:Tstringlist ;
s1:TStringStream ;
procedure TSendTread.Execute;
begin
paralist := Tstringlist.Create ;
s1 := TStringStream.Create('');
PARALIST.ADD('na=user') ;
PARALIST.ADD('pass=pass') ;
PARALIST.ADD('ac=edit') ;
PARALIST.ADD('id=54') ;
Synchronize(run);
end;
不会用哟..
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms;type
TMyThread = class(TThread)
private
procedure pp;
protected
procedure Execute; override;
end; TFrmMain = class(TForm)
MainMenu1: TMainMenu;
...
var
FrmMain: TFrmMain;implementation
...
...{ TInitThread }procedure TMyThread.pp;
var
paralist:Tstringlist ;
s1:TStringStream ;
begin
paralist := Tstringlist.Create ;
s1 := TStringStream.Create('');
PARALIST.ADD('na=user') ;
PARALIST.ADD('pass=pass') ;
PARALIST.ADD('ac=edit') ;
PARALIST.ADD('id=54') ;
form1.IdHTTP1.Request.Referer := 'http://www.xxxxxxx.com/index.html' ;
try
idhttp1.Post('http://www.xxxxxxx.com/edit.asp', paralist, s1) ;
finally
paralist.Free ;
s1.Free ;
end;
end;
procedure TInitThread.Execute;
begin
FreeOnTermiNate:=True;
Synchronize(PP);
end;...
end.
unit Unit_FrmMain;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms;type
TMyThread = class(TThread)
private
procedure pp;
protected
procedure Execute; override;
end; TFrmMain = class(TForm)
MainMenu1: TMainMenu;
...
var
FrmMain: TFrmMain;implementation
...
...{ TMyThread }procedure TMyThread.pp;
var
paralist:Tstringlist ;
s1:TStringStream ;
begin
paralist := Tstringlist.Create ;
s1 := TStringStream.Create('');
PARALIST.ADD('na=user') ;
PARALIST.ADD('pass=pass') ;
PARALIST.ADD('ac=edit') ;
PARALIST.ADD('id=54') ;
form1.IdHTTP1.Request.Referer := 'http://www.xxxxxxx.com/index.html' ;
try
idhttp1.Post('http://www.xxxxxxx.com/edit.asp', paralist, s1) ;
finally
paralist.Free ;
s1.Free ;
end;
end;
procedure TMyThread.Execute;
begin
FreeOnTermiNate:=True;
Synchronize(PP);
end;...
end.
type TPPThread=class(TThread)
protected
procedure pp;
public
procedure Execute;override;
end;procedure TPPThread.Execute;
begin
while not Terminated do
begin
Synchronize(pp);
Sleep(100);
end;
end;procedure TPPThread.pp;
begin
Form1.pp;
end;
protected
procedure pp; //改成 pp:TThreadMethod更好, 这样就通用了。
public
procedure Execute;override;
end;