==========
Rendezvous
==========

A simple ActiveX EXE that is used to coordinate multiple clients.

Rendezvous has a singleton Monitor object that raises an event
back to all clients.  Clients get a reference to Monitor by
creating a Connector Class in Rendezvous and invoking its read-
only Monitor property.

This is a really, really condensed example of the classic Coffee
Monitor tutorial's demo/testbed from the VB6 documentation and
samples.  It is a very standard technique that's been around
since the beginning, though for some reason it escapes so many
VB6 coders.

--------
Overview
--------

You have an application where many instances are run, but for
whatever reason you want them to be able to coordinate among
themselves.

Here this is done using a separate ActiveX EXE that implements
a Connector Class used to:

    o Obtain a reference to the global singleton Monitor
      object.

    o Determine whether you are the "first" instance of the
      application to connect.

    o Report your termination (really your disconnection) by
      releasing your Connector object reference.

    o Receive termination (disconnection) reports for other
      instances via an event.

-------
Details
-------

When a client creates an instance of Connector a new singleton
Monitor object is created if it doesn't exist yet.  When the
client calls Connector.Monitor to get a reference to the Monitor
object they also pass the value of App.ThreadID.

The first client to call Connector.Monitor has its ThreadID set
as the single internal global value gFirstUserThreadID.

Any client can then call the Boolean property Connector.FirstUser
passing its App.ThreadID as many times as it wants.  This returns
True if they are the "first user."

Once this is set up, whenever a client releases its Connector
object the Monitor event TerminateNotification is raised to all
remaining clients.  The Connector can be released explicitly or
by stack teardown when the parent Form or Class terminates and
unloads.

-----------------
Building the Demo
-----------------

WARNING:

    You *do* always run the VB6 IDE with admin rights, right?
    If not you can create some real messes in your registry,
    especially when using Windows Vista or later!

Open Rendezvous.vbp in the VB6 IDE (running elevated) and Make
the project.

Then Open ClientApp.vbp in the VB6 IDE.  If necessary, set the
reference to "A Multi-instance Rendezvous Component" before
compiling.  Then Make this client project.

----------------
Running the Demo
----------------

Run several instances of ClientApp.exe, for example by double-
clicking on its icon in Explorer.

The first client will display the fact of its "firstness" and
the others their "not firstness."

Close some instances, fire up more.  Only the true "first"
instance will ever report itself as first though.

-------
Cleanup
-------

I hate to let junk accumulate in the registry, perhaps you do
as well.

In Explorer, drag and drop Rendezvous.exe's icon onto the
AxExeUnreg.vbs icon to unregister the server.

If you change your mind and want to run the demo again, just
drag/drop it onto the AxExeReg.vbs icon instead!

This isn't perfect, since it may leave orphaned typelib
registration in your registry.  To find these entries use
RegEdit and Find on:

    A Multi-instance Rendezvous Component

and:

    Rendezvous.Connector
