F fxh7622 Unregistered / Unconfirmed GUEST, unregistred user! 2008-02-25 #1 我想实现这样的效果,将一个类的对象作为参数传递给一个线程,如何实现呢?? 线程里面又如何将这个参数转换成这样类的对象呢?? 请高手帮助啊。
H happycyp Unregistered / Unconfirmed GUEST, unregistred user! 2008-02-25 #2 unit Unit1; interface uses Classes; Type TMyThread = class(TThread) AComponent: TComponent; public constructor Create(CreateSuspended: Boolean; Component: TComponent); reintroduce; destructor Destroy; override; end; implementation { TMyThread } constructor TMyThread.Create(CreateSuspended: Boolean; Component: TComponent); begin AComponent := Component; inherited Create(CreateSuspended); end; destructor TMyThread.Destroy; begin AComponent.Free; inherited Destroy; end; end. 仅供参考。
unit Unit1; interface uses Classes; Type TMyThread = class(TThread) AComponent: TComponent; public constructor Create(CreateSuspended: Boolean; Component: TComponent); reintroduce; destructor Destroy; override; end; implementation { TMyThread } constructor TMyThread.Create(CreateSuspended: Boolean; Component: TComponent); begin AComponent := Component; inherited Create(CreateSuspended); end; destructor TMyThread.Destroy; begin AComponent.Free; inherited Destroy; end; end. 仅供参考。
F fxh7622 Unregistered / Unconfirmed GUEST, unregistred user! 2008-02-25 #3 我创建的线程是没用用Delphi的线程类来做的是使用CreateThread函数来创建的。如何做呢?
张 张辉明 Unregistered / Unconfirmed GUEST, unregistred user! 2008-02-25 #4 HANDLE CreateThread ( SEC_ATTRS SecurityAttributes, ULONG StackSize, SEC_THREAD_START StartFunction, PVOID ThreadParameter, ULONG CreationFlags, PULONG ThreadId ); 把类的指针,放在pvoid参数中,传入。
HANDLE CreateThread ( SEC_ATTRS SecurityAttributes, ULONG StackSize, SEC_THREAD_START StartFunction, PVOID ThreadParameter, ULONG CreationFlags, PULONG ThreadId ); 把类的指针,放在pvoid参数中,传入。
F fxh7622 Unregistered / Unconfirmed GUEST, unregistred user! 2008-06-02 #5 我知道放入pvoid中,可是如何放入呢? 我使用这种方法好像不行啊。 //创建线程时 CreateThread(nil, 0, @ServerWorkerThread, Pointer(@Self),0, ThreadID); //线程中的处理 function ServerWorkerThread(m_NetServerointer):Integer;stdcall; var Net:TNetServer; begin Net:=TNetServer(m_NetServer^); end; 哪位仁兄帮助啊。
我知道放入pvoid中,可是如何放入呢? 我使用这种方法好像不行啊。 //创建线程时 CreateThread(nil, 0, @ServerWorkerThread, Pointer(@Self),0, ThreadID); //线程中的处理 function ServerWorkerThread(m_NetServerointer):Integer;stdcall; var Net:TNetServer; begin Net:=TNetServer(m_NetServer^); end; 哪位仁兄帮助啊。