VB6 enables you to create two types of COM components:
The difference between these server component types is with respect to the
client application.
When a server component runs out-of-process with respect to its client, it
has the following characteristics:
It can run as a standalone application completely apart from the client.
It does not share the same address space under the operating system.
-
Its public creatable classes can be instantiated either as SingleUse or MultiUse objects.
(See "The Instancing Property of COM Component Classes"
later in this chapter for a discussion of these concepts.)
When a server component runs in-process with its client, it has these important features:
The server component and client share the same executable space under the operating
system.
-
The server component and client share some of the same memory.
-
An in-process server component's public creatable classes can be instantiated
only as MultiUse objects. (See "The Instancing Property of COM Component
Classes" later in this chapter.)
As you might imagine, there are pros and cons to both in-process and out-of-process
server components.
Performance: In-Process Server Components Win the Contest
Because an in-process server component shares the same process space with
its client at runtime, communication between the in-process server component and its client
can avoid the ActiveX interface. The client can therefore call the in-process server component
very efficiently.
Flexibility and Availability: Out-of-Process Server Components Win the Contest
Here is a list of things only an out-of-process server component can do:
-
Provide classes that are either SingleUse or MultiUse. (See
"The Instancing Property of COM Component Classes" later in this chapter.)
-
Display modeless forms.
-
Use the End statement (although not recommended in every application because
it prevents the firing of an Unload or Terminate event).