L
leadroy
Unregistered / Unconfirmed
GUEST, unregistred user!
function PressReg(SoftIDchar):boolean;var mstr:string; k:cardinal;begin S1:=tIDUDPServer.Create(nil); s1.OnUDPRead:=MyControl.Onread; {这个是动态建件的事件} mstr:=regpub.Enc('LEADCK'+'|'+SoftID+'|'+getkey); EventFinish:=false; k:=gettickcount; s1.Send(regpub.CheckServerIP,9091,mstr); while (gettickcount-k<4000) and (not eventfinish) do application.ProcessMessages;end;下面是事件class procedure MyControl.Onread(Sender: TObject; AData: TStream;ABinding: TIdSocketHandle);var temp:TStringStream;begin try temp:=TStringStream.Create(''); temp.CopyFrom(adata,adata.Size); EventFinish:=true; RetValue:=regpub.Dec(temp.DataString); finally temp.Free; end;end;问题出在当我发送了信息给远程服务器等远程服务器回复时,这个onread事件不能被执行.只有一种方法就是在发送后放一个showmessage,说明这个事件不能得到CPU处理时间,问题应该出在application.ProcessMessages上面,请高手指点.备注:所有代码在一个单元里面.没有FORM