ObjectPool
Reuses released objects to reduce repeated allocations. The general pool keeps separate stacks by runtime type, while the text-block and run pools use dedicated stacks for their respective object types.
Objects with an attached tooltip are not cached. ClearPool(PoolId) disposes cached objects that implement IDisposable.
Definition
Namespace:Telerik.WinForms.Documents.UI
Assembly:Telerik.WinControls.RadSpreadsheet.dll
Syntax:
public class ObjectPool
Inheritance: objectObjectPool
Constructors
Creates an empty object pool. Objects are created on demand and become available for reuse after release.
public ObjectPool()
Methods
Removes all cached objects from the specified pool and disposes cached objects that implement IDisposable.
public void ClearPool(ObjectPool.PoolId poolId)
The pool to clear.
Retrieves a cached object from the general pool, or creates one if none is available for the requested type.
public T CreateObject<T>() where T : new()
T
An instance of T. A newly created TextBlock has its style
reset to null.
Retrieves a cached object from the specified pool, or creates one if none is available.
public T CreateObject<T>(ObjectPool.PoolId poolID) where T : new()
The cache to use for the object.
Returns:T
An instance of T. A newly created TextBlock has its style
reset to null.
The specialized pools (TextBlockPool, RunPool, and SpaceRunPool) do not separate cached objects by type. Use each specialized pool consistently with one concrete type.
Returns an object to the specified pool for reuse.
public void ReleaseObject(object obj, ObjectPool.PoolId poolID)
The object to cache.
poolIDObjectPool.PoolIdThe cache that will hold the object.
The object is cached as-is. Objects with an attached tooltip are not cached; if such an object implements IDisposable, it is disposed instead. The specialized pools do not separate cached objects by type, so use each specialized pool consistently with one concrete type.
Returns an object to the general pool for reuse by requests for the same concrete type.
public void ReleaseObject(object obj)
The object to cache.
The object is cached as-is. Objects with an attached tooltip are not cached; if such an object implements IDisposable, it is disposed instead.