[DUG] AV problem in a thread object
Grant Brown
grant at sitedoc.com.au
Wed Sep 28 16:57:54 NZST 2005
Hi all,
Using Delphi 5 and Midware components
I keep getting an AV when trying to access the Response Buffer from a
thread. I have listed the relevant parts of the code below.
Could anyone have a look and tell me what the problem is.
TIA
Regards
Grant Brown
----------- Code snippets ---------------
#### the threads excute method
procedure TServerThreadObj.Execute;
begin
while not terminated do
begin
FResponseBuffer.Rewrite; #### AV at this point
##### the actual thread object class
type
TServerThreadObj = class(TThread)
private
protected
public
FResultStatus: ^Integer;
FResponseBuffer: TMWBuffer;
UserDataPointer: Integer;
OwnerHandle: Integer;
procedure Execute; override;
published
end;
#### Part of the Server Object class
private
FWorkerThread: TServerThreadObj;
FWindowHandle: Integer;
procedure WMFinish(var msg: TMessage); message WM_FINISH;
procedure WndProc(var MsgRec: TMessage); virtual;
#### the server object excute method
procedure TServerObjectSENDLIST_USER_FULL.Execute;
begin
ResponseBuffer.Rewrite;
FWorkerThread := TServerThreadObj.Create(TRUE);
FWorkerThread.UserDataPointer := Self.UserData;
FWorkerThread.FResponseBuffer := TObject(ResponseBuffer) as TMWBuffer;
FWorkerThread.FResultStatus := @ResultStatus;
FWorkerThread.OwnerHandle := FWindowHandle;
FWorkerThread.FreeOnTerminate := TRUE;
FWorkerThread.Resume;
end;
More information about the Delphi
mailing list