Re: Help in design/threading

Andrew Gayter <[email protected]> Fri, 26 Jul 2002 15:39:55 +0100
Newsgroups gmane.comp.windows.devel.vbcom
Message-ID <[email protected]>
Hi,

For starters connection pooling is available for Windows 98, it's
actually part of the MDAC protocol stack and isn't platform dependent.
Secondly, GetObject does work with vb6 objects - infact it works with
all COM objects. It works in two ways. The creation of new objects and
the retrieval of objects from what is called the running object table,
or ROT. In your case you wanting to implement a singleton object that
hold onto two connections? The object is to be accessible from other
applications? To do this you will have to manually install your
singleton into the ROT and then you can use GetObject and a moniker to
retrieve a reference to the instance. If memory serves there is example
code of how to do this @ www.devx.com - search for lightweight COM
objects
Alternatively, you can implement the functionality yourself by using
IRunningObject table and register and revoke - win32API, but I would
recommend you writing this as a C++ ATL server.
MS put loads of objects into the ROT e.g. ppt, word docs etc, you can
view what objects are registered on your machine by using rotviewer.

I'm somewhat confused by

>2. Create our database component as single-threaded so that our clients
>could share the object.

How can you share an object that is single threaded? Surely, the sharing
of an object would mean that it would be multithreaded with
synchronization?? If it remains as single-threaded only one client will
be able to access functionality in a serialized fashion?

Create an ActiveX exe and mark it as thread-per object. Design two
classes, one, say ConnectionManager and another DBConnection. When the
client first starts up he looks for ConnectionManager in the ROT. If
it's not there create it and register it in the ROT. Then ask the
ConnectionManager to create one of the two types of connections for you,
which can be the same method, but obviously with different connection
strings. The connection manager should use CreateObject NOT new to
create the connection objects.

This design will give you the behavior that you want i.e. a single point
to get hold of connections and connection objects that are running on
their own threads (inside their own STAs).

Hope this helps?

A




-----Original Message-----
From: Technical discussion of VBCOM [mailto:[email protected]]
On Behalf Of kheyrollahi
Sent: 26 July 2002 10:23
To: [email protected]
Subject: [VBCOM] Help in design/threading

Hi all,

I have got a problem in designing the lowermost layer. Actually since we
are going to deploy our software on windows 98, we cannot have the
luxury
of connection sharing (Am I wrong?). And since we wouldn't have more
than
4-5 computers on the network and all of them must be able to work stand-
alone in case a netwrok problem occurs or the master computer fails (and
our clients usually do not have even the slightest knowledge of
computer), we have designed a pretty sohpisticated abstratction in terms
of connection management and fault tolerance which is done in our
Database layer so that business layer only receives data services and
doesn't know much about how it is done on on which connection (local
database vs. remote database). We have also placed merge replication
which solves inconsistencies of databases.

Now we want to create only one object of that class per machine (which
opens and holds on to two connections one to local database and one to
remote) and business layer tries to get the object if it is there and
create it if it is not there, so we wouldn't be opening a new connection
per each biz objects. How we could implement it:

1. Biz objects try to use GetObject(,"MyComponent.MyClass") which sadly
does not work for components written in VB.

2. Create our database component as single-threaded so that our clients
could share the object.

3.I couldn't think of anything else !:)
Thank you very much for your comments and suggestions, in advance.

Ali

You can read messages from the VBCOM archive, unsubscribe from VBCOM, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

You can read messages from the VBCOM archive, unsubscribe from VBCOM, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.