procedure autothread.Execute;begin { Place thread code here } while not terminated do begin autottoscop;////是个声明的第一个过程 autosctotop;//是个声明的第二个过程 end;end; 两个过程的程序大体相同,就是对不同的表进行操作。 第一个过程的程序: procedure autothread.autottoscop; begin //sleep(3000); //写代码 if autot.Active then autot.close; autot.Open; if autot.RecordCount =0 then begin autot.close; enabledop; exit; end; if autot.RecordCount <>0 then begin 对表进行写操作 end; 第二个过程: 第一个过程的程序: procedure autothread.autosctotop; begin //sleep(3000); //写代码 if autosc.Active then autosc.close; autosc.Open; if autosc.RecordCount =0 then begin autot.close; enabledop; exit; end; if autosc.RecordCount <>0 then begin 对表进行写操作 end;当表autot,autosc中的记录都为0时,程序没有问题。 当第一过程中的表autot有记录时,执行完autottoscop,到第二个过程的时候就出错了。
还有,我在线程中的两个过程是顺序执行,没有同步啊?
{ Place thread code here }
while not terminated do
begin autottoscop;////是个声明的第一个过程
autosctotop;//是个声明的第二个过程
end;end;
两个过程的程序大体相同,就是对不同的表进行操作。
第一个过程的程序:
procedure autothread.autottoscop;
begin
//sleep(3000);
//写代码
if autot.Active then autot.close;
autot.Open;
if autot.RecordCount =0 then
begin
autot.close;
enabledop;
exit;
end;
if autot.RecordCount <>0 then
begin
对表进行写操作
end;
第二个过程:
第一个过程的程序:
procedure autothread.autosctotop;
begin
//sleep(3000);
//写代码
if autosc.Active then autosc.close;
autosc.Open;
if autosc.RecordCount =0 then
begin
autot.close;
enabledop;
exit;
end;
if autosc.RecordCount <>0 then
begin
对表进行写操作
end;当表autot,autosc中的记录都为0时,程序没有问题。
当第一过程中的表autot有记录时,执行完autottoscop,到第二个过程的时候就出错了。
但在.exe中执行时,线程进行一次循环后,整个应用程序就退出了,是Delphi4的毛病吗