timer
ir := MilliSecondsBetween(now, dtBegin) mod 1000;
if (ir >= 0) and (ir <= iInterval) then
begin
。。。。
end
这样做不对
请问该怎么做?
...全文
7388打赏收藏
udp设置超时问题
大家好 我想在规定3秒内udp控件发数据 超过3秒则提示超时 请问怎么做 timer ir := MilliSecondsBetween(now, dtBegin) mod 1000; if (ir >= 0) and (ir <= iInterval) then begin 。。。。 end 这样做不对 请问该怎么做?
if iSecond>=3 then
begin
超时处理
end else
begin
没有超时处理
end;
就是这个逻辑 具体的,只能你自己处理
一般超时处理 可设一个全局变量 icount
比如登录程序 再设一个全局变量 biSLogin
当登录成功是 biSLogin :=True;
把timer 设为1秒
在timer 事件中
if biSLogin then exit;
inc(icount );
if icount>2 then
begin
超时处理
终止timer
end else
begin
重发登录信息
end;
timer 事件:
ir := MilliSecondsBetween(now, dtBegin) mod 1000;
if MilliSecondsBetween(now, dtBegin) >= Trunc(10000 * iTimeOver) then
begin
if not OrderEdThePIC then
begin
Timer2.Enabled := False;
OrderEdThePIC := True;
end;
end
else
if (ir >= 0) and (ir <= 3000) then
begin
if (Device_Type <>'00') then
begin
c :=MakeComm(Char(StrToHex(Device_Type)));
UDP.Send('255.255.255.255',HIS_PORT,c);
end else
begin
//如果指定为
c:=MakeComm(Char(StrToHex('11')));
UDP.Send('255.255.255.255',HIS_PORT,c);