本文整理匯總了VB.NET中System.EnterpriseServices.ObjectPoolingAttribute類的典型用法代碼示例。如果您正苦於以下問題:VB.NET ObjectPoolingAttribute類的具體用法?VB.NET ObjectPoolingAttribute怎麽用?VB.NET ObjectPoolingAttribute使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了ObjectPoolingAttribute類的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: Activate
' 導入命名空間
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