Subject | RE: [IBO] Multithreaded application problem |
---|---|
Author | Jason Wharton |
Post date | 2004-10-27T03:06:10Z |
Try making it so that the ClientSession owns all the subsequent data access
components (you appear to be doing this, but just review other code that I
don't see here to be sure).
You may also do all object instantiation PRIOR to the execute method when
instantiating the thread instance so that all the creation of components is
done using the main thread instead of the sub-thread.
You might also consider using native IBO components instead of the TDataset
ones to eliminate extra layers of baggage. TIB_Cursor for datasets and
TIB_DSQL for statements.
Jason Wharton
components (you appear to be doing this, but just review other code that I
don't see here to be sure).
You may also do all object instantiation PRIOR to the execute method when
instantiating the thread instance so that all the creation of components is
done using the main thread instead of the sub-thread.
You might also consider using native IBO components instead of the TDataset
ones to eliminate extra layers of baggage. TIB_Cursor for datasets and
TIB_DSQL for statements.
Jason Wharton
> -----Original Message-----
> From: Robert martin [mailto:rob@...]
> Sent: Tuesday, October 26, 2004 6:17 PM
> To: IBObjects@yahoogroups.com
> Subject: [IBO] Multithreaded application problem
>
>
>
> Hi All
>
> We are having strange problems with a multithreaded
> application using IBO
> components. This app runs fine on many (dozens) of machines
> however on
> Newer P4 machines running at 2.8Ghz (may be other higher
> speeds but thus far
> only 2.8 machines have been tested) and windows XP SP2 we are having
> problems.
>
> The following code is in the execute part of a thread. The
> code crashes
> (Locks?) when trying to open the increment table. The
> exception either does
> not trigger or fails to save any message to the error file.
>
> I have traced the code by logging actions to a log. All
> components are
> created on the fly (No DM used here). TwsTable inherits from
> TIBOTable.
> The main VCL thread is running simultaneously. The
> application appears to
> lock, using 100% processor time. It never recovers.
>
> Am I doing something obviously wrong / dangerous? Any suggestions?
>
>
> if (ClientSesion = Nil) then begin
> ClientSesion := TIB_Session.Create(Nil);
>
> ClientSesion.UseCursor := False;
>
> //RM 22/06/2004 Firebird - Create Database for all
> table components
> IBODataBase := TIBODatabase.Create(ClientSesion);
> IBODataBase.Path := Owner.DataBasefullPath;
> IBODataBase.Password := WS_DB_PASSWORD;
> IBODataBase.Username := WS_DB_USERNAME;
> IBODataBase.Protocol := cpTCP_IP;
> IBODataBase.PageSize := WS_DB_PAGESIZE;
> IBODataBase.IB_Session := ClientSesion;
> IBODataBase.SQLDialect := 3;
> IBODataBase.Connected := True;
>
> IncrementTable :=
> TwsTable.Create(ClientSesion);
> IncrementTable.IB_Connection := IBODataBase;
> IncrementTable.TableName := 'Increment';
> try
> IncrementTable.OpenIfClosed;
> except
> on e: exception do begin
> RecordServerError('ROB TEST **', 'Processing Thread - 2d', 1, Now,
> e.message); //RM 27/10/2004 Testing
> end;
> end;
> end;
>
> while Terminated = False do begin
> ........
>
>
> Rob Martin
> Software Engineer
>
> phone 03 377 0495
> fax 03 377 0496
> web www.chreos.com
> Wild Software Ltd
>