Using Shared Property Manager
What is Shared Property Manager?
We know that most of the times MTS objects are stateless. But sometimes it becomes
necessary to persist properties or state of the object. MTS provides this functionality
via Shared Property Manager.
There are three objects which we need to deal with :
SharedPropertyManager is at top level in the hierarchy. It allows a property to be shared
across multiple clients.
SharedPropertyGroup represents a logical grouping of properties and is next in the
SharedProperty represents actual property of an object.
How to code for shared properties?
First you need to set reference to Shared Property Manager Type Library.
Consider following code :
Dim propmanager As MTxSpm.SharedPropertyGroupManager
Dim propgrp As MTxSpm.SharedPropertyGroup
Dim prop As MTxSpm.SharedProperty
Dim flag As Boolean
Dim myvar as String
Set propmanager = New MTxSpm.SharedPropertyGroupManager
Set propgrp = propmanager.CreatePropertyGroup("mygrp", LockSetGet, Process,
Set prop = propgrp.CreateProperty("myprop", flag)
If flag = False Then
prop.Value = "myvalue"
You need to add this code in the method in which you want to set or get the property
value. Note that the property is always created even though it already exists. The boolean
value(flag) tells you weather the property already exists or not.
The LockSetGet places lock on the property while setting or retrieving the
value. Other possible value is LockMethod which locks all the properties
the current method finishes.
The Process indicates that the property will be destroyed when the package is
shut down. Other possible value is Standard in which case the property is
destroyed when all the client references are released.