ObjectPoolingAttribute::MaxPoolSize Property
.NET Framework (current version)
Gets or sets the value for the maximum size of the pool.
Assembly: System.EnterpriseServices (in System.EnterpriseServices.dll)
MaxPoolSize represents the maximum number of pooled objects that the pooling manager will create, both actively used by clients and inactive in the pool. When creating objects, the pooling manager checks to verify that the maximum pool size has not been reached and, if it has not, the pooling manager creates a new object to dispense to the client. If the maximum pool size has been reached, client requests are queued and receive the first available object from the pool in the order in which they arrived. Object creation requests time-out after a specified period.
The following code example demonstrates the use of this property.
[assembly:ApplicationName("ObjectInspector")]; [assembly:ApplicationActivation(ActivationOption::Server)]; [assembly:System::Reflection::AssemblyKeyFile("Inspector.snk")]; [JustInTimeActivation] [ObjectPooling(MinPoolSize=2,MaxPoolSize=100,CreationTimeout=1000)] public ref class ObjectInspector: public 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: virtual void Activate() override { MessageBox::Show( String::Format( "Now entering...\nApplication: {0}\nInstance: {1}\nContext: {2}\n", ContextUtil::ApplicationId.ToString(), ContextUtil::ApplicationInstanceId.ToString(), ContextUtil::ContextId.ToString() ) ); } virtual void Deactivate() override { MessageBox::Show( "Bye Bye!" ); } // This object can be pooled. virtual bool CanBePooled() override { return (true); } };
.NET Framework
Available since 1.1
Available since 1.1
Show: