ObjectPoolingAttribute.MinPoolSize Property

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Gets or sets the value for the minimum size of the pool.

Namespace:   System.EnterpriseServices
Assembly:  System.EnterpriseServices (in System.EnterpriseServices.dll)

public int MinPoolSize { get; set; }

Property Value

Type: System.Int32

The minimum number of objects in the pool.

MinPoolSize represents the number of objects that are created when the application starts and the minimum number of objects that are maintained in the pool while the application is running. If the number of available objects in the pool drops below the specified minimum, new objects are created to meet any outstanding object requests and refill the pool. If the number of available objects in the pool is greater than the minimum number, those surplus objects are destroyed during a clean-up cycle.

The following code example demonstrates the use of this property.

[JustInTimeActivation]
[ObjectPooling(MinPoolSize=2, MaxPoolSize=100, CreationTimeout=1000)]
public class ObjectInspector : ServicedComponent
{

    public string IdentifyObject (Object obj)
    {
        // Return this object to the pool after use.
        ContextUtil.DeactivateOnReturn = true;

        // Get the supplied object's type.        
        Type objType = obj.GetType();

        // Return its name.
        return(objType.FullName);

    }

    protected override void Activate()
    {
        MessageBox.Show( String.Format("Now entering...\nApplication: {0}\nInstance: {1}\nContext: {2}\n",
                                       ContextUtil.ApplicationId.ToString(), ContextUtil.ApplicationInstanceId.ToString(),
                                       ContextUtil.ContextId.ToString() ) );
    }

    protected override void Deactivate()
    {
        MessageBox.Show("Bye Bye!");
    }

    // This object can be pooled.
    protected override bool CanBePooled()
    {
        return(true);
    }

}

.NET Framework
Available since 1.1
Return to top
Show: