Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 4 of 4 total
Thread Multi-Threading using Datamodules
Fri, Dec 22 2006 6:00 PMPermanent Link

"Johnnie Norsworthy"
I am working on an application that I would like to be able to create an
arbitrary number of threads at run-time that will all access a local
database (not C/S for this version) and the internet through HTTP.

Can I just design a single datamodule with all the database access stuff and
other non-visual components then create that datamodule dynamically,
renaming the session as needed on each? I was going to try a threading
component (BMDThread) which I'd also just add at design time. Or do I have
to create all of the components at run-time when the thread is created?

The work to be done by my application is simple. For each row in a table, a
HTTP web search is done asynchronously (ICS components) and the results
posted back to the table. Since I can do an async request for a number of
dynamically created HTTP components and share event code, this may be
another approach to consider.

-Johnnie
(Yes, working on the holiday weekend, while the phone doesn't ring)

Sat, Dec 23 2006 8:33 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Johnnie


If you figure it out PLEASE post an example. I'm sure it must be possible to create multiple instances of a datamodule but I've never figured it out.

In all the threading stuff I do I create sessions, databases, queries and tables within the thread.


Roy Lambert
Wed, Dec 27 2006 5:35 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Johnnie,

<< Can I just design a single datamodule with all the database access stuff
and other non-visual components then create that datamodule dynamically,
renaming the session as needed on each? I was going to try a threading
component (BMDThread) which I'd also just add at design time. Or do I have
to create all of the components at run-time when the thread is created? >>

AFAIK, yes, although I vaguely remember some rumblings about data module
creation/destruction not being thread-safe in one of the Delphi versions due
to unlocked access to a global list of the created data modules.  Google
Groups will probably be your best bet in confirming that (search on "Delphi
TDatamodule thread-safe").  We use web modules (ISAPI) on our web site and
they are just like data modules and work just fine.

You can also just use the TDBISAMSession.AutoSessionName property to
auto-assign the session name as necessary.

--
Tim Young
Elevate Software
www.elevatesoft.com

Tue, Jan 2 2007 11:29 AMPermanent Link

> You can also just use the TDBISAMSession.AutoSessionName property

This is the most important aspect of getting this working. I've certainly
used data modules in threads just fine. Creating them dynamically isn't a
problem so long as the auto-session name is active at design time.

/Matthew Jones/
Image