The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.
ObjectPoolingAttribute Constructor ()
.NET Framework (current version)
Initializes a new instance of the ObjectPoolingAttribute class and sets the Enabled, MaxPoolSize, MinPoolSize, and CreationTimeout properties to their default values.
Assembly: System.EnterpriseServices (in System.EnterpriseServices.dll)
The following table shows initial property values for an instance of ObjectPoolingAttribute.
Property | Value |
|---|---|
Enabled | true |
MaxPoolSize | -1 |
MinPoolSize | -1 |
CreationTimeout | -1 |
The following code example demonstrates the use of this attribute.
#using <System.Windows.Forms.dll> #using <System.Transactions.dll> #using <System.EnterpriseServices.dll> using namespace System; using namespace System::EnterpriseServices; using namespace System::Windows::Forms; [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: