Delphi中的线程类--之(2)[7]

[入库:2005年8月18日] [更新:2007年3月24日]

本文简介:选择自 raptor 的 blog

如果execute发生异常,则通过acquireexceptionobject取得异常对象,并存入线程类的ffatalexception成员中。

最后是线程结束前做的一些收尾工作。局部变量freethread记录了线程类的freeonterminated属性的设置,然后将线程返回值设置为线程类的返回值属性的值。然后执行线程类的doterminate方法。

doterminate方法的代码如下:

procedure tthread.doterminate;

begin

  if assigned(fonterminate) then synchronize(callonterminate);

end;

很简单,就是通过synchronize来调用callonterminate方法,而callonterminate方法的代码如下,就是简单地调用onterminate事件:

procedure tthread.callonterminate;

begin

  if assigned(fonterminate) then fonterminate(self);

end;

本文关键:Thread Event CriticalSection Synchronize
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top