Click to open or copy the freclien project files.
Click to open or copy the freserve project files.
This sample consists of the following parts.
The FRECLIEN sample spawns multiple threads to create and use the COBall COM object provided by the FRESERVE free-threaded server. The COBall object itself spawns no threads; instead, it passively responds to IBall interface requests from many possible client threads. The FRECLIEN client creates and controls one COBall object through the IBall interface that the object exposes. As three of FRECLIEN's threads move the ball through calls to IBall::Move, the remaining main thread uses a system timer to obtain timed updates of the COBall object's position, size, and color. This main thread uses that data, obtained by calling the IBall::GetBall method, to display graphical snapshot images of the ball in the client's main window.
In the FRESERVE sample, the COBall object internally updates its color property to reflect the last thread that called the object's Move method. The display thread uses this data for each ball image it displays. As the ball moves, it changes color to reflect each thread that moves the ball. As the ball moves, it also leaves a trail that provides a striking visual history of these passing threads. This trail demonstrates that, with COM's free threading model, every thread that makes interface requests to the same object accesses the object on the calling thread. Each different color of the single ball object represents a different calling thread.
This sample uses native compiler COM support. It gives an example of a custom COM interface that marshals the RECT and POINT structures with the free-threaded model. It demonstrates the use of the exclude attribute of the #import directive.
See also Compiler COM Support, the SDK FRESERVE sample, and the SDK FRECLIEN sample.