ObjectPoolingAttribute.CreationTimeout Properti
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Mendapatkan atau mengatur lamanya waktu untuk menunggu objek tersedia di kumpulan sebelum melemparkan pengecualian. Nilai ini dalam milidetik.
public:
property int CreationTimeout { int get(); void set(int value); };
public int CreationTimeout { get; set; }
member this.CreationTimeout : int with get, set
Public Property CreationTimeout As Integer
Nilai Properti
Nilai waktu habis dalam milidetik.
Contoh
Contoh kode berikut menunjukkan penggunaan properti ini.
[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);
}
};
[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);
}
}
<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
Keterangan
Menentukan berapa lama klien akan menunggu, dalam milidetik, agar objek dikembalikan dari kumpulan.
Berlaku untuk
Berkolaborasi dengan kami di GitHub
Sumber untuk konten ini dapat ditemukan di GitHub, yang juga dapat Anda gunakan untuk membuat dan meninjau masalah dan menarik permintaan. Untuk informasi selengkapnya, lihat panduan kontributor kami.