W
wishme3
Unregistered / Unconfirmed
GUEST, unregistred user!
在定时器中建一线程,来定时处理数据,做发如下:
type
TInitThread = class(TThread)
private
procedure ProData;
protected
procedure Execute;
override;
end;
...
...
procedure TInitThread.Execute;
begin
FreeOnTermiNate:=True;
Synchronize(ProData);
end;
procedure TInitThread.ProData;
begin
Screen.Cursor:=crHourGlass;
{做处理的代码}
Screen.Cursor:=crDefault;
end;
procedure TForm1.Timer2Timer(Sender: TObject);
var NewThread:TInitThread;
begin
NewThread:=TInitThread.Create(false);
end;
问题:
1、以上做发是否可行,创建线程的方发是否正确
2比如timer是每隔1秒做一次,那么在timer中每秒都创建一个线程,不会造成资源的浪费?
并且影响性能?
type
TInitThread = class(TThread)
private
procedure ProData;
protected
procedure Execute;
override;
end;
...
...
procedure TInitThread.Execute;
begin
FreeOnTermiNate:=True;
Synchronize(ProData);
end;
procedure TInitThread.ProData;
begin
Screen.Cursor:=crHourGlass;
{做处理的代码}
Screen.Cursor:=crDefault;
end;
procedure TForm1.Timer2Timer(Sender: TObject);
var NewThread:TInitThread;
begin
NewThread:=TInitThread.Create(false);
end;
问题:
1、以上做发是否可行,创建线程的方发是否正确
2比如timer是每隔1秒做一次,那么在timer中每秒都创建一个线程,不会造成资源的浪费?
并且影响性能?