multithreading - TThread 中的继承问题,在 D2010 中的工作方式似乎与 D7 不同

标签 multithreading delphi delphi-2010

在我的应用程序中,我有两个线程对象(Outer 和 Sash),它们继承自 TThread 类型的基本线程对象 (FrameObject)。这在 D7 中一切正常。该应用程序需要扩展,我借此机会将其移至 D2010 - 然而,当我尝试编译 Delphi 时,提示 FrameObject Create 方法声明与之前的声明不同。

类类型和构造函数如下所示;

TFrameObject = class(TThread)

constructor TFrameObject.Create(BuildType: TBuildType; OnBatchStep: TBatchNotify; OnThreadComplete: TNotifyTermination);
begin
  inherited Create(True);
  ...
end;


TOuter = class (TFrameObject)

constructor Create(BuildType: TBuildType; OnBatchStep: TBatchNotify;  OnThreadComplete: TNotifyTermination; ExceptionHandler: TExceptionHandler);
begin
  inherited create(BuildType, OnBatchStep, OnThreadComplete);
  fExceptionHandler := ExceptionHandler;
  ...
end;

TSash = class (TFrameObject)
constructor Create(BuildType: TBuildType; OnBatchStep: TBatchNotify;  OnThreadComplete: TNotifyTermination; ExceptionHandler: TExceptionHandler);
begin
  inherited create(BuildType, OnBatchStep, OnThreadComplete);
  fExceptionHandler := ExceptionHandler;
  ...
end;

D2010 代码是 D7 源文件的直接副本,正如我所说,这一切在 D7 中都能正常工作(也许不应该!) - 那么我哪里出错了?

最佳答案

检查在多个单元中声明的类型,其中一个在接口(interface)中使用,另一个在实现部分中使用,例如 TFrameObject 声明中的 TBuildType (在接口(interface)部分)将解析为 UnitA.TBuildType 并实现为 UnitB.TBuildType

关于multithreading - TThread 中的继承问题,在 D2010 中的工作方式似乎与 D7 不同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4795563/

相关文章:

Java Tomcat,底层 Netty 线程没有停止

delphi - 如何将方法作为回调传递给 Windows API 调用?

Delphi 编辑器配色方案

delphi - 如何在Delphi组件中存储大文本?

c# - 取消 CancellationToken 是否会导致 CancellationToken 异常?

java - 我想使用执行器线程池在我设计的 Web 应用程序中通过电子邮件发送运行时通知

java - 为什么放置 start() 命令时会有所不同?

delphi - 为什么子类中的接口(interface)没有释放

delphi - Indy idHttp 卡住 - 如何使用 keep-alive?

Delphi IDE 由于隐藏的模式窗口而锁定