Object pool is a feature of COM +. this avoids the creation of complex objects every time. therefore, many com written in VB are added to COM + without any changes. in fact, the com written in VB6 is apartment-threaded, and the object pool is not supported at all.
I have confirmed this issue with you today.
Problem: A com written in VB implements the iobjectcontrol or objectcontrol of COM +.. NET Enterprise Service. the object pool can be implemented in this way, just like the database connection pool. avoid creating objects every time. therefore, these methods are generally implemented. ------------------------------------------------ Private sub objectcontrol_activate ()
End sub Private function objectcontrol_canbepooled () as Boolean
Objectcontrol_canbepooled = true
End Function Private sub objectcontrol_deactivate ()
End sub ------------------------------------ Then I thought it was the same as VC or. net is implemented in the same way. assume that: 1. when a component is put in COM +, you can set the pool size, including the minimum pool and the maximum pool. 2. if I set an appropriate pool and the object is created multiple times, some objects do not need to be instantiated. After testing, we found that these two points are not correct. Finally, we found that VB does not support object pool. Microsoft's original document: Object pooling is not possible for components created by VB6. The following problems are: Since VB6 does not support object pooling, why does it need to implement the objectcontrol interface? And ourCodeThis interface is also generally implemented. To answer this question, I chose a com template called by ASP with an explanation. That is to say, the constructor and activate are called sequentially every time an object is created. On the contrary, deactivate and terminate are also called during release. For activate, the context of the active object can be called, and deactivate releases the reference of the context.
If your COM + component does not access objectcontext at all, you do not need this interface. The general template is as follows: Option explicit
'---------------------------------------------------------------------------
-----
'Clarations
'---------------------------------------------------------------------------
-----
'* Interfaces
Implements comsvcslib. objectcontrol
'* Module level variables
Private m_objcontext as comsvcslib. objectcontext
Private m_blnmts as Boolean
Private const m_modulename as string = "nameofclasshere" 'used
Error Handling
Private m_strusername as string
Private m_strpassword as string
'---------------------------------------------------------------------------
-----
'Properties
'---------------------------------------------------------------------------
-----
'---------------------------------------------------------------------------
-----
'Methods
'---------------------------------------------------------------------------
-----
'---------------------------------------------------------------------------
-----
'Mts/COM + Methods
'---------------------------------------------------------------------------
-----
Private sub objectcontrol_activate ()
'*************************************** ***************************
'* Objectcontrol_activate
'*----------------------
'* One of the methods of the MTS/COM + objectcontrol interface. This
Subroutine
'* Is used to set the objectcontext and the MTS/COM + Boolean.
'*************************************** ***************************
'* Get the context from the application
Set m_objcontext = getobjectcontext ()
'* Boolean for MTS/COM + or not
M_blnmts = Not (m_objcontext is nothing)
End sub
Private function objectcontrol_canbepooled () as Boolean
'*************************************** ***************************
'* Objectcontrol_canbepooled
'*-------------------------
'* One of the methods of the MTS/COM + objectcontrol interface. This
Subroutine
'* Is used to specify if this object can be pooled. in Visual Basic 6,
This
'* Must be set to false.
'*************************************** ***************************
'* Must be set to false in Visual Basic 6
Objectcontrol_canbepooled = false
End Function
Private sub objectcontrol_deactivate ()
'*************************************** ***************************
'* Objectcontrol_deactivate ()
'*--------------------------
'* One of the methods of the MTS/COM + objectcontrol interface. This
Subroutine
'* Is used to destroy the object. The objectcontext is set to nothing
Here.
'*************************************** ***************************
Set m_objcontext = nothing
End sub
--------------------