This sample demonstrates the use of an ActiveX object pointer being passed to an external (and optionally remote) ActiveX server component. The server then periodically calls a method on this object pointer. This has the effect of a server-initiated callback to the client, which can be a much better application model than the polling a client application might have to do otherwise to find the status of a server. Although this demo simply returns the time to the client, it could just as easily return data, news, or other information it has been told the client wants to know. The benefit here is that the server does all the work looking for data the client might need and the client does other work, only being interrupted when the server actually has something that interests it.
The server in this project uses a visible form purely for demonstration purposes. There is no functional need for the server to have any UI, though state information presented through a UI can help with debugging or run-time monitoring needs. (Note, state monitoring requirements could also be addressed by providing a status method on the server that could be queried by a monitor application.)
File | Description |
Clbk_cli.vbp | Client component project file. |
Clbk_cli.frm | Client main form. |
Clbk_cli.bas | Client main/global utility module. |
Clbk_cli.cls | Client class module. |
Clbk_svr.vbp | Server component project file. |
Clbk_svr.frm | Server status indicator form. |
Clbk_svr.bas | Server main/global utility module. |
Clbk_svr.cls | Server class module. |
Callback.txt | A text file containing a project overview and description. |
From the Visual Basic File menu, choose Open Project and select the Clbk_svr.vbp file, which is listed in the Samples directory. Press F5 or choose Start from the Run menu to run the server project.
Once running, this project temporarily registers its classes in the system registry. You can then start a second instance of Visual Basic to run Clbk_cli.vbp, the client that uses the class modules defined in Clbk_svr.vbp.
Note The Automation server can be run on the same machine as the client, or it can be run on a remote machine to benefit from distributed processing power and support multi-user access. The Automation server does not need to be recompiled or changed in any way to support this location independence.