RE: Maintaining State Between Web Pages




Reply to Old Pedant:

Thanks for your response. You asked a few good questions/issues.

A. This is a business application and will not run on an independent ISP.

B. "Depends on what "between pages" means.":
Each time the user hits enter or clicks a "Save" button, this is a page
refresh.

C. "If you used apartment threading, this is a bad idea.:
The srever runs on the client machine. All method calls are performed
sequentailly. I used Apartment threading model.

The server is written in Delphi 7. I purchased Delphi 1 about 10 years ago
and fell in love with it. It is my hobby. I know Delpi will never get me a
job, but I like it.

Below is information regarding the servers Instance and Threading Model
taken from Delphi Help. [bold]What would your recommendation be regarding
Instance and Threading Model.[/bold]

INSTANCE MEANING

When your COM application creates a new COM object, it can have any of the
following instancing types:

1. Internal: The object can only be created internally. An external
application cannot create an instance of the object directly.

2. Single Instance: Allows only a single COM interface for each executable
(application), so creating multiple instances results in launching multiple
instances of the application.

3. Multiple Instance: Specifies that multiple clients can connect to the
application. Any time a client requests the object, a separate instance is
created within a single process space. (That is, there can be multiple
instances in a single executable.)

Note: When your Automation object is used only as an in-process server,
instancing is ignored.


THREADING MODEL

Choose the threading model to indicate how COM serializes calls to your
Automation object’s interface. The threading model you choose determines how
the object is registered. You must make sure that your object implementation
adheres to the model selected.

Automation Objects can have one of the following:

1. Single: Only one client thread can be serviced at a time. COM serializes
all incoming calls to enforce this. Your code needs no thread support.

2 Apartment: Each object instantiated by a client is accessed by one thread
at a time. You must protect against multiple threads accessing global memory,
but objects can safely access their own instance data (object properties and
members).

3. Free: Each object instance may be called by multiple threads
simultaneously. You must protect instance data as well as global memory.

4. Both: This is the same as the Free-threaded model, except that all
callbacks supplied by clients are guaranteed to execute in the same thread.
This means you do not need protect values supplied as parameters to callback
functions.

5. Neutral: Multiple clients can call the object on different threads at the
same time, but COM ensures that no two calls conflict. You must guard against
thread conflicts involving global data and any instance data that is accessed
by more than one method. This model should not be used with objects that have
a user interface. This model is only available under COM+. Under COM, it is
mapped to the Apartment model.

Note: Under COM+, the serialization of calls to your object is also
influenced by how it participates in activities. This can be configured using
the COM+ page of the type library editor or the COM+ Component Manager.

.