Page 1 of 1

May be error in NonBlocking realization?

Posted: Thu 02 Oct 2008 11:39
by eml79
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?

Posted: Fri 03 Oct 2008 12:58
by Plash
This is not a bug. The thread is started in the AfterConstruction method of TThread. This method is executed after the constructor.

Posted: Tue 07 Oct 2008 05:22
by eml79
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)

Posted: Wed 08 Oct 2008 07:43
by Plash
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.