O'Reilly logo

Microsoft® Visual Basic® .NET Programmer's Cookbook by Matthew MacDonald

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Create a Pooled Component

Problem

You want to use COM+ object pooling to maintain a pool of preinitialized objects.

Solution

Derive your class from ServicedComponent, add the ObjectPooling attribute, and override the CanBePooled method.

Discussion

With object pooling, a "pool" of available, instantiated objects is retained permanently. When a client creates an object, COM+ provides a preinitialized object from the pool. When a client releases an object, it isn’t destroyed, but is instead returned to the object pool, where it remains ready to serve another client. Object pooling is most often used for one of two reasons in a distributed application:

  • To reduce the cost of creating an expensive object. Most objects can be created quite quickly and easily. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required