Visual Basic Concepts
Code components, formerly called OLE servers, are libraries of objects that provide an easy way to package your code for reuse. For example, you can create libraries of procedures that can be used with Microsoft Visual Basic or with desktop applications that host Visual Basic for Applications, such as Microsoft Office.
With the Enterprise Edition of Visual Basic, code components can become parts of enterprise systems, running unattended on remote computers to provide data services and business rules. The information in "Scalability and Multithreading" and "Asynchronous Call-Backs and Events" will be of particular interest in this context.
Code components can be wizards and add-ins for Visual Basic. Extending the Visual Basic Environment with Add-Ins, in the Component Tools Guide, describes how to create wizards and add-ins. Many of the topics in this chapter provide useful background information for creating add-ins.
"Building Code Components" assumes familiarity with the material in "General Principles of Component Design" and "Debugging, Testing, and Deploying Components," as well as "Programming with Objects," in the Visual Basic Programmer’s Guide.
The following topics describe key features of code components created with Visual Basic.
Global Objects and Code Libraries
Create libraries of procedures you can call without explicitly creating objects — as if the procedures were part of Visual Basic. |
|
Scalability and Multithreading
When a component has to handle multiple requests, Visual Basic provides two ways to prevent long tasks from blocking short ones: multithreading and SingleUse classes. |
|
Asynchronous Call-Backs and Events
Defines asynchronous processing, and discusses two ways to notify clients that asynchronous tasks are complete: by raising events, or by implementing interfaces that include call-back methods. |
|
Displaying Forms From Code Components
Displaying modal and modeless forms from in-process and out-of-process components. |
|
How Object Creation Works in Visual Basic Components
In certain circumstances — for example, with SingleUse objects — the way you create the object can affect its behavior. |
|
How Binding Affects ActiveX Component Performance
The performance of your component is affected by the way clients declare the variables they use to keep references to your objects. |
|
How Marshaling Affects ActiveX Component Performance
How you declare method arguments in out-of-process components can have a big effect on performance. |
Coffee2.vbp, CoffWat2.vbp, MTCoffee.vbp
Coffee2.vbp and CoffWat2.vbp demonstrate two techniques for asynchronous notifications — events and call-back methods on a secondary interface — and provide an example of all-code timers you can use instead of the Timer control. MTCoffee.vbp illustrates some features of multithreading. The sample applications are listed in the Samples directory. |
For More Information See "Creating an ActiveX EXE Component," for step-by-step procedures that illustrate multithreading and asynchronous processing. Similar step-by-step procedures in "Creating an ActiveX DLL," illustrate global objects and modeless forms. Visual Basic code components can also provide ActiveX documents, as discussed in "Building ActiveX Documents."