W
wishme3
Unregistered / Unconfirmed
GUEST, unregistred user!
//下面创建一个简单的线程类
type
TInitThread = class(TThread)
private
procedure ProData;
protected
procedure Execute; override;
end;
Procedure TForm1.RecvData()//接收socket上收到的数据
var
NewThread:TInitThread;
begin
//Socket接收到的数据放入一数组中
//然后启动一线程来处理该数组数据
NewThread:=TInitThread.Create(false);
//这里每次收到数据都创建一个线程,在哪里销毁?不消毁资源会耗尽
end;
procedure TInitThread.Execute;
begin
FreeOnTermiNate:=True;
Synchronize(ProData);
end;
//重载Execute方法
procedure TInitThread.ProData;
begin
Screen.Cursor:=crHourGlass;
DealData; //处理数组上的数据
Screen.Cursor:=crDefault;
end;
type
TInitThread = class(TThread)
private
procedure ProData;
protected
procedure Execute; override;
end;
Procedure TForm1.RecvData()//接收socket上收到的数据
var
NewThread:TInitThread;
begin
//Socket接收到的数据放入一数组中
//然后启动一线程来处理该数组数据
NewThread:=TInitThread.Create(false);
//这里每次收到数据都创建一个线程,在哪里销毁?不消毁资源会耗尽
end;
procedure TInitThread.Execute;
begin
FreeOnTermiNate:=True;
Synchronize(ProData);
end;
//重载Execute方法
procedure TInitThread.ProData;
begin
Screen.Cursor:=crHourGlass;
DealData; //处理数组上的数据
Screen.Cursor:=crDefault;
end;