把控件用线程包装起来呀.
TSockThread = class(TThread)
SakMail1: TSakMail;
...
public
constructor Create(IP, Port:string;Resume:boolean);
end;
constructor TsockThread.Create(IP, Port:string;Resume:boolean);
begin
Inherited Create(resume);
SakMail:=TSakMail.Create;
//调用参数参考它本身的create方法
SakMail.RemoteHost:=IP;
//属性名称可能不对
SakMail.RemotePort:=Port;
//属性名称可能不对, 数据类型可能不对
end;
procedure TSockThread.Execute;
begin
//add what you want todo
here
// rememberdo
n't exit this procedure until
// close socket or terminate connection
// because exit this procedure means close thread
end;
end;
简单地, 就是从菜单中new一个thread, 然后修改对应的代码