J
junrui2726
Unregistered / Unconfirmed
GUEST, unregistred user!
本人刚刚接触线程,有很多不明白的,希望大家帮帮。有一个线程(TsendThread),我在TsendThread.Execute里写代码,然后用一个时钟来控制,也就是在TForm1.Timer1Timer事件里调用线程,但cup占用很大的资源呀,是不是不能这样用,有什么好的办法解决吗?谢谢
简单的代码如下:
TsendThread.Execute
MyStream:TWinSocketStream;
begin
MyStream:=TWinSocketStream.Create(ClientSocket1.Socket,50000);
-----------
if MyStream.WaitForData(5000) then
begin
--------
end
end
procedure TForm1.Timer1Timer(Sender: TObject);
var
NewTsendThread: TsendThread;
begin
newTsendThread:=TsendThread.Create(false);
end;
简单的代码如下:
TsendThread.Execute
MyStream:TWinSocketStream;
begin
MyStream:=TWinSocketStream.Create(ClientSocket1.Socket,50000);
-----------
if MyStream.WaitForData(5000) then
begin
--------
end
end
procedure TForm1.Timer1Timer(Sender: TObject);
var
NewTsendThread: TsendThread;
begin
newTsendThread:=TsendThread.Create(false);
end;