Figure 3    Global Variables

Server
Type
Threading
Model
Main STA
Access
Secondary STA
Access
MTA
Access
Global Variable
Scope
ActiveX DLL or
ActiveX Control
Single Threaded
Apartment Threaded
Direct
Direct
Proxy
Direct
Proxy
Proxy
Process-wide
Thread-specific
ActiveX EXE Thread Per Object N/A N/A N/A Object-specific
Thread Pool (n==1) N/A N/A N/A Process-wide
Thread Pool (n>1) N/A N/A N/A Thread-specific


Figure 4     Object Environments and Global Variables

Scenario Share Global Variables?
Objects within a single MTS activity Yes
Objects within different MTS activities Sometimes
Objects created by a single Internet Explorer Web page Yes
Objects created by distinct Internet Explorer Web pages in a single frameset Yes
Objects created in distinct Internet Explorer top-level windows No
Objects created on a single ASP page Yes
Objects created on different ASP pages in the same session Sometimes
Objects created on different ASP pages in different sessions Sometimes


Figure 7   Object Initialization Routine


 Dim m_spgm as ISharedPropertyGroupManager
 Dim m_spg as ISharedPropertyGroup
 Dim m_spnSharedSum as ISharedProperty
 Dim m_spnAccesses as ISharedProperty
 Sub ObjectControl_Activate()
   Rem create a manager
   Set m_spgm _
       = New MTxSpm.SharedPropertyGroupManager
   Dim isoMode As Long, relMode As Long
   Dim bExists as Boolean
   isoMode = LockMethod
   relMode = Process
   Rem create (or open) lock 
   Set m_spg = _
     m_spgm.CreatePropertyGroup("MyGlobals", _
                     isoMode, relMode, bExists)
   Rem open references to each property
   Set m_spnSharedSum = _
      m_spg.CreateProperty("g_nSharedSum", bExists)
   Set m_spnAccesses = _
      m_spg.CreateProperty("g_nAccesses" , bExists)
 End Sub