ObjectPoolingAttribute 생성자
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
ObjectPoolingAttribute 클래스의 새 인스턴스를 초기화합니다.
오버로드
| Name | Description |
|---|---|
| ObjectPoolingAttribute() |
클래스의 ObjectPoolingAttribute 새 인스턴스를 초기화하고 , Enabled, MaxPoolSize및 MinPoolSize 속성을 기본값으로 설정합니다CreationTimeout. |
| ObjectPoolingAttribute(Boolean) |
클래스의 새 인스턴스를 ObjectPoolingAttribute 초기화하고 속성을 설정합니다 Enabled . |
| ObjectPoolingAttribute(Int32, Int32) |
클래스의 새 인스턴스를 ObjectPoolingAttribute 초기화하고 및 MaxPoolSize 속성을 설정합니다MinPoolSize. |
| ObjectPoolingAttribute(Boolean, Int32, Int32) |
클래스의 새 인스턴스를 ObjectPoolingAttribute 초기화하고 , Enabled및 MaxPoolSize 속성을 설정합니다MinPoolSize. |
ObjectPoolingAttribute()
클래스의 ObjectPoolingAttribute 새 인스턴스를 초기화하고 , Enabled, MaxPoolSize및 MinPoolSize 속성을 기본값으로 설정합니다CreationTimeout.
public:
ObjectPoolingAttribute();
public ObjectPoolingAttribute();
Public Sub New ()
예제
다음 코드 예제에서는이 특성의 사용을 보여 줍니다.
#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);
}
};
using System;
using System.EnterpriseServices;
using 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 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);
}
}
Imports System.EnterpriseServices
Imports 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 Class ObjectInspector
Inherits ServicedComponent
Public Function IdentifyObject(ByVal obj As [Object]) As String
' Return this object to the pool after use.
ContextUtil.DeactivateOnReturn = True
' Get the supplied object's type.
Dim objType As Type = obj.GetType()
' Return its name.
Return objType.FullName
End Function 'IdentifyObject
Protected Overrides Sub Activate()
MessageBox.Show(String.Format("Now entering..." + vbLf + "Application: {0}" + vbLf + "Instance: {1}" + vbLf + "Context: {2}" + vbLf, ContextUtil.ApplicationId.ToString(), ContextUtil.ApplicationInstanceId.ToString(), ContextUtil.ContextId.ToString()))
End Sub
Protected Overrides Sub Deactivate()
MessageBox.Show("Bye Bye!")
End Sub
' This object can be pooled.
Protected Overrides Function CanBePooled() As Boolean
Return True
End Function 'CanBePooled
End Class
설명
다음 표에서는 ObjectPoolingAttribute인스턴스에 대한 초기 속성 값을 보여 줍니다.
| 재산 | 가치 |
|---|---|
| 활성화됨 | true |
| MaxPoolSize | -1 |
| MinPoolSize | -1 |
| CreationTimeout | -1 |
적용 대상
ObjectPoolingAttribute(Boolean)
클래스의 새 인스턴스를 ObjectPoolingAttribute 초기화하고 속성을 설정합니다 Enabled .
public:
ObjectPoolingAttribute(bool enable);
public ObjectPoolingAttribute(bool enable);
new System.EnterpriseServices.ObjectPoolingAttribute : bool -> System.EnterpriseServices.ObjectPoolingAttribute
Public Sub New (enable As Boolean)
매개 변수
- enable
- Boolean
true개체 풀링을 사용하도록 설정하려면 그렇지 않으면 . false
예제
다음 코드 예제에서는 새 ObjectPoolingAttribute를 만듭니다.
[ObjectPooling(true)]
public ref class ObjectPoolingAttributeCtorBool : public ServicedComponent
{
};
[ObjectPooling(true)]
public class ObjectPoolingAttribute_Ctor_Bool : ServicedComponent
{
}
<ObjectPooling(True)> _
Public Class ObjectPoolingAttribute_Ctor_Bool
Inherits ServicedComponent
End Class
적용 대상
ObjectPoolingAttribute(Int32, Int32)
클래스의 새 인스턴스를 ObjectPoolingAttribute 초기화하고 및 MaxPoolSize 속성을 설정합니다MinPoolSize.
public:
ObjectPoolingAttribute(int minPoolSize, int maxPoolSize);
public ObjectPoolingAttribute(int minPoolSize, int maxPoolSize);
new System.EnterpriseServices.ObjectPoolingAttribute : int * int -> System.EnterpriseServices.ObjectPoolingAttribute
Public Sub New (minPoolSize As Integer, maxPoolSize As Integer)
매개 변수
- minPoolSize
- Int32
최소 풀 크기입니다.
- maxPoolSize
- Int32
최대 풀 크기입니다.
예제
다음 코드 예제에서는 새 ObjectPoolingAttribute를 만듭니다.
[ObjectPooling(1, 10)]
public ref class ObjectPoolingAttributeCtorIntInt : public ServicedComponent
{
};
[ObjectPooling(1, 10)]
public class ObjectPoolingAttribute_Ctor_Int_Int : ServicedComponent
{
}
<ObjectPooling(1, 10)> _
Public Class ObjectPoolingAttribute_Ctor_Int_Int
Inherits ServicedComponent
End Class
적용 대상
ObjectPoolingAttribute(Boolean, Int32, Int32)
클래스의 새 인스턴스를 ObjectPoolingAttribute 초기화하고 , Enabled및 MaxPoolSize 속성을 설정합니다MinPoolSize.
public:
ObjectPoolingAttribute(bool enable, int minPoolSize, int maxPoolSize);
public ObjectPoolingAttribute(bool enable, int minPoolSize, int maxPoolSize);
new System.EnterpriseServices.ObjectPoolingAttribute : bool * int * int -> System.EnterpriseServices.ObjectPoolingAttribute
Public Sub New (enable As Boolean, minPoolSize As Integer, maxPoolSize As Integer)
매개 변수
- enable
- Boolean
true개체 풀링을 사용하도록 설정하려면 그렇지 않으면 . false
- minPoolSize
- Int32
최소 풀 크기입니다.
- maxPoolSize
- Int32
최대 풀 크기입니다.
예제
다음 코드 예제에서는 새 ObjectPoolingAttribute를 만듭니다.
[ObjectPooling(true, 1, 10)]
public ref class ObjectPoolingAttributeCtorBoolIntInt :
public ServicedComponent
{
};
[ObjectPooling(true, 1, 10)]
public class ObjectPoolingAttribute_Ctor_Bool_Int_Int : ServicedComponent
{
}
<ObjectPooling(True, 1, 10)> _
Public Class ObjectPoolingAttribute_Ctor_Bool_Int_Int
Inherits ServicedComponent
End Class