Since TDataModule creation and destruction synchronizes via a shared global lock, what else isn't thread safe when it comes to data modules?

Since TDataModule creation and destruction synchronizes via a shared global lock, what else isn't thread safe when it comes to data modules?

I need to do some entirely independent SQL work (DBX) in a background thread. Delphi XE6.

Comments

  1. A TDataModule only has a chance of being threadsafe if every piece of code in it (or called, however indirectly, by it) is threadsafe.

    VCL controls (in general) are not Threadsafe.  Some RTL functions are, some are not.

    When dealing with Databases, you will usually need to have  a dedicated connection for use by each Thread.

    ReplyDelete
  2. The issue for me is that this behavior is not documented, and not knowing about it makes it easy to create deadlocks.

    I guess I'll have to plow through the source code :(

    ReplyDelete
  3. In IBO there's the concept of a sessioncomponent. It's documented that if this component is created first on a DM (for designtime-people theres the edit creation order, as you all know), all other will follow. Sadly, i do not know about DBX and can not add anything useful.

    ReplyDelete

Post a Comment