现在我在做一个含有线程的程序,其中这个线程是有几个自定义的进程串在一起组成的,进程中包含ADO对象(多线程组件),运行时发现,该线程可以全速运行,挂起,但不能terminate,在试图使用挂起后,再free的方法也不能实现,而且出现程序死掉的情况,线程开始一开始运行就设置freeonterminate:=true,请问高手,这是怎么回事,希望大家尽快帮忙,小弟在这给大家跪下啦~~~~~~
另外本人对文件打印颇有一点心得,谁有兴趣要?
另外本人对文件打印颇有一点心得,谁有兴趣要?
调试欢乐多
unit threadunit;interfaceuses
Classes {$IFDEF MSWINDOWS} , Windows {$ENDIF};type
Tmythread = class(TThread)
private
procedure SetName;
protected
procedure Execute; override;
end;implementation
uses input,publicdeclare,mainform,sysgraphics;
{ Important: Methods and properties of objects in visual components can only be
used in a method called using Synchronize, for example, Synchronize(UpdateCaption); and UpdateCaption could look like, procedure Tmythread.UpdateCaption;
begin
Form1.Caption := 'Updated in a thread';
end; }{$IFDEF MSWINDOWS}
type
TThreadNameInfo = record
FType: LongWord; // must be 0x1000
FName: PChar; // pointer to name (in user address space)
FThreadID: LongWord; // thread ID (-1 indicates caller thread)
FFlags: LongWord; // reserved for future use, must be zero
end;
{$ENDIF}{ Tmythread }procedure Tmythread.SetName;
{$IFDEF MSWINDOWS}
var
ThreadNameInfo: TThreadNameInfo;
{$ENDIF}
begin
{$IFDEF MSWINDOWS}
ThreadNameInfo.FType := $1000;
ThreadNameInfo.FName := 'threadpath';
ThreadNameInfo.FThreadID := $FFFFFFFF;
ThreadNameInfo.FFlags := 0; try
RaiseException( $406D1388, 0, sizeof(ThreadNameInfo) div sizeof(LongWord), @ThreadNameInfo );
except
end;
{$ENDIF}
end;procedure Tmythread.Execute;
begin
SetName;
{ Place thread code here }
try
begin
if jsmodel then
begin
ybcomp;
yhbcomp;
phcomp;
ltcomp;
hpcomp;
dlcomp;
gzcomp;
zxcomp;
dzcomp;
pscomp;
zscomp;
kycomp;
jsmodel:=false;
end
else
begin
case procedurebz of
1:ybcomp;
2:yhbcomp;
3:phcomp;
4:ltcomp;
5:hpcomp;
6:dlcomp;
7:gzcomp;
8:zxcomp;
9:dzcomp;
10:pscomp;
11:zscomp;
12:kycomp;
end;
end;
end;
except
begin
mainthread.terminate;
jsmodel:=false;
end;
end;
form2.button3.Enabled:=true;
form2.Button2.Enabled:=false;
form2.Button15.Enabled:=false;
if form10<>nil then
begin
form10.Enabled:=true;
form10.Button1.Enabled:=true;
form10.Button2.Enabled:=false;
form10.Button3.Enabled:=false;
end;
jsbz:=0;
mtime:=0;
stime:=0;
end;end.我看delphi帮助里写的好象有问题,terminate根本不是什么boolean型,是个过程啊,真把我给搞糊涂了