CONNECT: Use of Connection Points

Click to open or copy the CONNECT project files.

Note   This is a modification of the ATL sample Connect, to demonstrate Compiler COM support for connection point sinks. The DRIVE client is a native implementation, whereas the MDRIVE client slightly belabors COM-correctness in using a ClassFactory to create sink objects. Neither DRIVE nor MDRIVE are dependent upon ATL or MFC for any COM support.

This sample illustrates the use and implementation of connection points (the IConnectionPointContainer and IConnectionPoint interfaces) in a multithreaded environment.

The server is implemented in Connect.dll. This DLL allows the creation of a CoRandom COM object, implemented by the CRandom C++ class. The COM object supports IRandom (a dual interface) and IConnectionPointContainer, and it accepts connections for the IRandomEvent interface.

The IRandom interface supports the following methods.

Start

Starts a thread inside the object.

Stop

Stops a thread inside the object.

StopAll

Stops all running threads.

When running, the secondary threads inside the object keep firing events through the connection point.

Two clients are provided: DRIVE and MDRIVE. They can be found in the DRIVE and MDRIVE subdirectories.

To run, build Connect.dll and register it. You can build and run Drive.exe  from a console, or build and run MDrive.exe directly from Visual C++.