NT/2000服务程序问题(100分)

B

beamgx

Unregistered / Unconfirmed
GUEST, unregistred user!
各位大哥:
请问为什么这东东启动后CPU占用率就成了100%?
代码如下:
svrs: TIdUDPServer;
svrc: TIdUDPClient;
procedure Tservice1.ServiceExecute(Sender: TService);
begin
try
svrc.Active :=true;
svrs.Active :=true;
while not terminated do;
finally
svrc.Active :=false;
svrs.Active :=false;
end;
end;
 
我没有看你的程序是干什么的。但是你至少要这麽改动一下:
while not terminated do
sleep(100);
否则CPU利用就是100%。
 
改成这样:
while not terminated do
begin
ServiceThread.ProcessRequests(False);
Sleep(100);
end;
OR
while not terminated do
ServiceThread.ProcessRequests(True);
 
to shiwee
用来接收UDP包处理后转发的
to xianjun
SLEEP期间会不会影响UDP的接收?
我先试:
while not terminated do ServiceThread.ProcessRequests(True);
 
问题解决,多谢!
 

Similar threads

S
回复
0
查看
712
SUNSTONE的Delphi笔记
S
S
回复
0
查看
744
SUNSTONE的Delphi笔记
S
S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
669
SUNSTONE的Delphi笔记
S
顶部