我现在写了一个程,是通过ADO调用ORACLE中一个过程,
由于这个过程要执行的时间很长,所以我在这里程序里用到了多线程.
写好后发现这个程序在关闭的时候不能正常关闭,
在调用的过程没有运行的时候能正常关闭,但是在过程运行的时候要是关闭程序就会报一个错,
报错说什么同步的问题,
请问是不是要在关闭程序的时候进行杀死线程的操作?
由于这个过程要执行的时间很长,所以我在这里程序里用到了多线程.
写好后发现这个程序在关闭的时候不能正常关闭,
在调用的过程没有运行的时候能正常关闭,但是在过程运行的时候要是关闭程序就会报一个错,
报错说什么同步的问题,
请问是不是要在关闭程序的时候进行杀死线程的操作?
我现在就是想要在关闭程序的时候强行把那个线程关掉,
可是我不知道怎么强行关闭这个线程.
private
FStop: Boolean;
FEvent:TSimpleEvent;
protected
procedure Execute; Override;
public
constructor Create;
destructor Destroy; override;
procedure Stop;
end;constructor TMyThread.Create;
begin
Inherited Create(TRUE);
FStop:=FALSE;
FEvent:=TSimpleEvent.Create;
end;procedure TMyThread.Execute;
begin
inherited;
FEvent.ResetEvent;
While FALSE=FStop do
begin
//执行操作
end;
FEvent.SetEvent;
end;procedure TMyThread.Stop;
begin
FStop := TRUE;
Resume ;
FEvent.WaitFor(5000);
end;destructor TMyThread.Destroy;
begin
FEvent.Free;
inherited;
end;释放前先调用 Stop来停止线程 .
h:Thandle;
procedure..
...
begin
h:=createthread(....);
end;
...
formclose
exitthread(hs);
行不行?