May be error in NonBlocking realization?

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
eml79
Posts: 13
Joined: Thu 28 Jun 2007 09:20

May be error in NonBlocking realization?

Post by eml79 » Thu 02 Oct 2008 11:39

ODAC version 6.25.2.15
Module OraClasses.pas

Code: Select all

constructor TExecThread.Create(MethodDesc: TMethodDesc; CreateSuspended: Boolean);
begin
  inherited Create(CreateSuspended);

  FMethodDesc := MethodDesc;
  FreeOnTerminate := True;
end;
In TOCIConnection.RunThread you call TExecThread.Create with CreateSuspended = False. Variable FMethodDesc assigned after of thread started and IMHO may be undefined in method TExecThread.Execute.
May be this is a bug?

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Fri 03 Oct 2008 12:58

This is not a bug. The thread is started in the AfterConstruction method of TThread. This method is executed after the constructor.

eml79
Posts: 13
Joined: Thu 28 Jun 2007 09:20

Post by eml79 » Tue 07 Oct 2008 05:22

Plash wrote:The thread is started in the AfterConstruction method of TThread. This method is executed after the constructor.
Delphi 5

Code: Select all

constructor TThread.Create(CreateSuspended: Boolean);
var
  Flags: DWORD;
begin
  inherited Create;
  AddThread;
  FSuspended := CreateSuspended;
  Flags := 0;
  if CreateSuspended then Flags := CREATE_SUSPENDED;
  FHandle := BeginThread(nil, 0, @ThreadProc, Pointer(Self), Flags, FThreadID);
end;
BeginThread call CreateThread. The thread is started in the Create method. (not in AfterConstruction)

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Wed 08 Oct 2008 07:43

Such code is only in Delphi 5. In newer versions of Delphi the thread is started in the AterConstruction method.
We'll fix our code to make it work correctly in Delphi 5.

Post Reply