Short question:
What's the difference between SingleUse and MultiUse ?
Long question:
I've been writing some sample code to see how different Instancing
values and threading models work. I tried all main combinations of
Instancing (Multiuse/Singleuse) and of Threading models (per
object/pool). Here's what I found:
MultiUse - Thread per Object
One new object for each request
SingleUse - Thread per Object
One new object for each request
MultiUse - Thread Pool (w/ 1 thread)
One object reused by all requests
SingleUse - Thread Pool (w/ 1 thread)
One new object for each request
The SU seems to be 100% superfluous: not only changing thread model
does not change the way it works, but whatever it does, it's exaclty
what MU does!
In order to test, I have created an ActiveXEXE with a form (frmTest)
and two classes (instancing is MU for one and SU for the other), both
have the same public method:
Public Sub Show(ByVal FormCaption As String, Top As Long, Left As
Long)
With frmTest
'First time show
If Not .Visible Then
.Top = Top
.Left = Left
.Visible = True
DoEvents
End If
.Caption = .Caption & FormCaption
End With
End Sub
The client calls this with something like:
Dim MUServ As New ActiveXServerEX E.MultiUseClass
Call MUServ.Show(Ind ex & " - " & Time, Top, Left + Width)
[Don't worry about the Top/Left stuff, it's irrelevant for this
discussion]
Can anybody shed some light on this topic once and for all ?
Thanks!
AK
What's the difference between SingleUse and MultiUse ?
Long question:
I've been writing some sample code to see how different Instancing
values and threading models work. I tried all main combinations of
Instancing (Multiuse/Singleuse) and of Threading models (per
object/pool). Here's what I found:
MultiUse - Thread per Object
One new object for each request
SingleUse - Thread per Object
One new object for each request
MultiUse - Thread Pool (w/ 1 thread)
One object reused by all requests
SingleUse - Thread Pool (w/ 1 thread)
One new object for each request
The SU seems to be 100% superfluous: not only changing thread model
does not change the way it works, but whatever it does, it's exaclty
what MU does!
In order to test, I have created an ActiveXEXE with a form (frmTest)
and two classes (instancing is MU for one and SU for the other), both
have the same public method:
Public Sub Show(ByVal FormCaption As String, Top As Long, Left As
Long)
With frmTest
'First time show
If Not .Visible Then
.Top = Top
.Left = Left
.Visible = True
DoEvents
End If
.Caption = .Caption & FormCaption
End With
End Sub
The client calls this with something like:
Dim MUServ As New ActiveXServerEX E.MultiUseClass
Call MUServ.Show(Ind ex & " - " & Time, Top, Left + Width)
[Don't worry about the Top/Left stuff, it's irrelevant for this
discussion]
Can anybody shed some light on this topic once and for all ?
Thanks!
AK
Comment