Multi-threaded environment

Discussion of open issues, suggestions and bugs regarding PgDAC (PostgreSQL Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
yozey
Posts: 32
Joined: Sat 17 Jan 2009 14:41

Multi-threaded environment

Post by yozey » Wed 25 Mar 2009 18:36

Hi is anyone using PgDAC in a multi-threaded environment? I'm trying this in a project but am receiving intermittent errors especially when initiating transactions.

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

Post by Plash » Thu 26 Mar 2009 08:01

You should use separate connections for each thread. If problems still occur, please send to pgdac*devart*com a complete small sample that demonstrates the problem, including the script for creating database objects.

snorkel
Posts: 384
Joined: Tue 08 Aug 2006 15:10
Location: Milwaukee WI USA

Re: Multi-threaded environment

Post by snorkel » Sat 28 Mar 2009 15:03

yozey wrote:Hi is anyone using PgDAC in a multi-threaded environment? I'm trying this in a project but am receiving intermittent errors especially when initiating transactions.
Yes, it works great, you have to use a connection per thread as Plash has stated. You might get it to work by using windows messages or some other means (critical sections etc) but one connection per thread works the best.

A queue or stack might work for you also depending on your needs.

yozey
Posts: 32
Joined: Sat 17 Jan 2009 14:41

Post by yozey » Sat 28 Mar 2009 20:07

Thanks for tip guys. I usually use a connection (separate) per thread, but this time I tried accessing a connection on a datamodule to perform some quick updates. So I'll stick to a dedicated connection for each thread.

Post Reply