ObjectPoolingAttribute.CreationTimeout Property

 

Gets or sets the length of time to wait for an object to become available in the pool before throwing an exception. This value is in milliseconds.

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

public int CreationTimeout { get; set; }

Property Value

Type: System.Int32

The time-out value in milliseconds.

Specifies how long a client will wait, in milliseconds, for an object to be returned from the pool.

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: