虚
虚心实腹
Unregistered / Unconfirmed
GUEST, unregistred user!
比如,在主线程中的代码
procedure TForm1.GetData;
var
smMsg:TSMMSG;
begin
with ADOQuery1 do
begin
close;
sql.Clear;
sqlstr:='select autono,sourceNumber,destiNumber,SMcontent,SerialNo,Status from T_SendingSM where status is null';
sql.add(sqlstr);
open;
smMsg.Msg := WM_SENDSM;
if RecordCount<>0 then
begin
while not eofdo
begin
application.ProcessMessages ;
smMsg.SourceNumber:=FieldByName('sourceNumber').asstring;
smMsg.DestinationNumber:=FieldByName('destiNumber').asstring;
smMsg.SMContent:=FieldByName('SMcontent').asstring;
smMsg.SMSerialNo := ProduceSerial;
// 取得短消息序列号
edit;
application.ProcessMessages ;
FieldByName('SerialNo').AsInteger :=smMsg.SMSerialNo ;
FieldByName('Status').AsString :='sending';
Form1.Dispatch(smMsg) ;
application.ProcessMessages ;
sleep(SmppSrvInfo.SendSM_Interval);
next;
end;
edit;
Post ;
end;
close;
end;
end;
在子线程中调用它
procedure TGetData.Execute;
begin
CoInitialize(nil);
{ Place thread code here }
inherited FreeOnTerminate := TRUE;
Form1.GetData;
end;
这样做和在子线程中实现同样的过程有区别吗?
procedure TForm1.GetData;
var
smMsg:TSMMSG;
begin
with ADOQuery1 do
begin
close;
sql.Clear;
sqlstr:='select autono,sourceNumber,destiNumber,SMcontent,SerialNo,Status from T_SendingSM where status is null';
sql.add(sqlstr);
open;
smMsg.Msg := WM_SENDSM;
if RecordCount<>0 then
begin
while not eofdo
begin
application.ProcessMessages ;
smMsg.SourceNumber:=FieldByName('sourceNumber').asstring;
smMsg.DestinationNumber:=FieldByName('destiNumber').asstring;
smMsg.SMContent:=FieldByName('SMcontent').asstring;
smMsg.SMSerialNo := ProduceSerial;
// 取得短消息序列号
edit;
application.ProcessMessages ;
FieldByName('SerialNo').AsInteger :=smMsg.SMSerialNo ;
FieldByName('Status').AsString :='sending';
Form1.Dispatch(smMsg) ;
application.ProcessMessages ;
sleep(SmppSrvInfo.SendSM_Interval);
next;
end;
edit;
Post ;
end;
close;
end;
end;
在子线程中调用它
procedure TGetData.Execute;
begin
CoInitialize(nil);
{ Place thread code here }
inherited FreeOnTerminate := TRUE;
Form1.GetData;
end;
这样做和在子线程中实现同样的过程有区别吗?