JavaScript Editor js editor     Web development 

Main Page

File: ...\Samples\Solution\Ffc\_PoolManager.scx

This sample demonstrates how to use the Pool Manager class, which manages a pool or collection of objects from a class and is useful when you need to use objects repeatedly for a short amount of time.

This sample contains the following classes.

Class Library Description



Manages a pool, or collection, of objects from a single class.

Pooling Objects

In this sample, forms are collected in a pool so that you can reuse any form that is available in the pool instead of having to create a new form when you select a customer from the drop-down list.

To use the Pool Manager class in this sample, the following Pool Manager class properties must be set in the Properties window:

cClassВ В В = frmCustomer

cClassLibrary = frmCustomer.vcx

Binding to Pool Manager Events

You can bind to _PoolManager events. In this sample, the form's Init event contains code that binds the form's custom handler methods, PoolManager_ObjectRequested and PoolManager_ObjectReturned, to the _PoolManager ObjectRequested and ObjectReturned events so that status can be reported on the sample form:

В Copy Code

Requesting Objects

To request an object from the pool, call the _PoolManager Get method.

To open a customer form in this sample

  1. Select a customer name from the drop-down list.

  2. Click View Customer.

You can open multiple forms by clicking View Customer repeatedly, which requests a form object from the Pool Manager class each time. The form's custom ViewCustomer method contains the following code:

В Copy Code
loForm = ThisForm.PoolManager.Get(m.lcCustID)
If Vartype(m.loForm) == "O"           

In this sample, the Get method returns an unused object that exists in the pool or creates a new object. When a new customer form is created, code in the form's Init event binds to the _PoolManager ObjectRequested and ObjectReturned methods using the private variable THISPOOLMANAGER created in the Get method:

В Copy Code

This event binding makes it possible for the form to call its Hide method instead of the Release method so the form returns to the pool instead of being destroyed.

Returning Objects

To return objects to the pool, call the _PoolManager Free method. In this sample, the form's QueryUnload event occurs when the customer form is closed and returns the form to the pool:

В Copy Code
If Vartype(This.oPoolManager) == "O"

See Also

JavaScript Editor js editor     Web development