Pool Manager Foundation Class

The Pool Manager Foundation Class manages a pool, or collection, of objects from a single class. When you need to use an object repeatedly for a short time, use the Pool Manager class.

Category Class information

Default Catalog

Visual FoxPro Catalog\Foundation Classes\Application

Class

_poolmanager

Base Class

Custom

Class Library

_poolmanager.vcx

Parent Class

Custom

Sample

...\Samples\Solution\Ffc\_PoolManager.scx

Remarks

This class works best if creating an instance of the object takes more time than obtaining an existing instance. This is commonly the case for the following types of classes:

  • Non-lightweight classes like the Visual FoxPro Form class.

  • Classes that contain resource-intensive code in the Init event of the form.

  • Classes that make use of external resources such as a database connection, automation server, or XML Web service.

You can add the Pool Manager class to the Form or Class designers from the Toolbox or to a project. When you add the Pool Manager class to a project, you can add the class or create a subclass.

The Pool Manager class uses the Visual FoxPro Collection base class for storing object references. For more information, see Collection Class.

For more information on using foundation classes, see Guidelines for Using Visual FoxPro Foundation Classes.

Properties, Events, Methods Description

cClass property

Name of the pooled class. You can also set this property by passing it as the first parameter when creating the pool manager object.

Default: None

cClassLibrary property

Library that contains the pooled class. The cClassLibrary property can point to a visual class library or a program file.

You can change this property by passing it as the second parameter when creating the pool manager object.

Default: None

lRaiseEvent property

If True (.T.), raises the ObjectRequested and ObjectReturned events. If you do not need these events to increase performance, set this property to False (.F.).

Default: .T.

nObjectsCreated property

Incremented each time an object is created

Default: 0

Get method

Returns an object reference to a pooled object. All parameters are passed to the Init event of a newly created object and the ObjectRequested event.

Syntax: Get( Param1, Param2, ...)

Return: Object

Arguments: Must pass parameters by value and cannot pass arrays to a pooled object.

Free method

Returns an object to the pool, making it available to the next Get method call.

Syntax: Free(@oObject)

Return: None

Arguments: oObjectis an object reference previously obtained from the Get method. The object can be passed by reference.

ObjectRequested event

Raised when an object is requested.

You can use this event to initialize an object based on the current parameters. When a pooled object binds to this event, the event is raised for every object, not just the object itself.

Syntax:ObjectRequested( oObject, Param1, Param2, ...)

Return: None

Arguments: oObjectis a reference to the pooled object that is returned to the caller. All parameters from the Get method are passed to this event as additional parameters.

ObjectReturned event

Raised when an object is returned to the pool by calling the Free method. When a pooled object binds to this event, the event is raised for every object, not just the object itself.

Syntax:ObjectReturned(oObject)

Return: None

Arguments: oObject is a reference to the pooled object.

See Also

Tasks

Pool Manager Sample

Reference

Visual FoxPro Foundation Classes A-Z

Concepts

Guidelines for Using Visual FoxPro Foundation Classes

Other Resources

Foundation Class Samples