【发布时间】:2014-07-31 04:10:05
【问题描述】:
如何在TThread 中设置自定义堆栈大小?我正在尝试重新引入TThread 的构造函数,但它说ThreadProc 丢失了,但它就在System.Classes 中。
type
TThreadHelper = class helper for TThread
constructor Create(const CreateSuspended: Boolean = False; const StackSize: Integer = 0); reintroduce;
end;
{ TThreadHelper }
constructor TThreadHelper.Create(const CreateSuspended: Boolean; const StackSize: Integer);
begin
Self.FSuspended := not Self.FExternalThread;
Self.FCreateSuspended := CreateSuspended and not Self.FExternalThread;
if not Self.FExternalThread then
begin
Self.FHandle := BeginThread(nil, StackSize, @ThreadProc, Pointer(Self), CREATE_SUSPENDED, Self.FThreadID);
if Self.FHandle = 0 then
raise EThread.CreateResFmt(@SThreadCreateError, [SysErrorMessage(GetLastError)]);
end
else
begin
Self.FHandle := Winapi.Windows.GetCurrentThread;
Self.FThreadId := GetCurrentThreadId;
end;
end;
[dcc32 错误] Project5.dpr(29): E2003 未声明的标识符: '线程进程'
【问题讨论】:
-
ThreadProc函数不供公众使用。它也将在单元的interface部分中定义。因此编译器看不到它。
标签: delphi delphi-xe6