Language
Edit

IDataObjectPool.AddPrefetchedObjectToPool(Int32, Object, Boolean) Method

Definition

Add a prefetched object to the pool with the specified ID.

public bool AddPrefetchedObjectToPool(int id, object objectToReturn, bool asNewest = true);
abstract member AddPrefetchedObjectToPool : int * obj * bool -> bool
Public Function AddPrefetchedObjectToPool (id As Integer, objectToReturn As Object, Optional asNewest As Boolean = true) As Boolean

Parameters

id
Int32

The id of object to add.

objectToReturn
Object

The prefetched object to add.

asNewest
Boolean

If true, add as newest item. If false, add as oldest item.

Returns

true if the object could be added to the pool, or false if not added, in which case caller should dispose of or destroy appropriately.

Remarks

A typical scenario would first call TryGetPrefetchedObject to get either an already prefetched object or if it does not exist, to get an unused object to then prefetch. Then, once prefetched, add it to the object pool using this method.

The object can either be added as the newest or the oldest. Adding one as the oldest is useful when you may want to speculatively add an existing item for reuse even though no one has asked for that item to be prefetched.

Applies to