RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
Mtx.CreateSharedPropertyGroup Function

Returns the interface for a SharedPropertyGroup that allows MTS objects within a server process to share state.

Pascal
function CreateSharedPropertyGroup(const Name: WideString): ISharedPropertyGroup;
C++
ISharedPropertyGroup CreateSharedPropertyGroup(const BSTR Name);

CreateSharedPropertyGroup returns an interface to a new shared property group. If a property group of the specified name exists, it returns a reference to the existing shared property group. Use this function to create and access the shared properties of a shared property group.  

CreateSharedPropertyGroup sets up a SharedPropertyGroup with the default values of LockSetGet for locking (isolation) mode, and Process for release mode. LockSetGet locks a property during every get or set operation on a shared property, making each operation atomic. This ensures that two clients cannot read or write to the same property at the same time, but it does not prevent other clients from concurrently accessing other properties in the same group. The Process release mode ensures that the property group is not destroyed until the process in which it was created has terminated. (Objects that hold references on a property group must still call Release on their references). 

To override these defaults, call CreateSharedPropertyGroupManager and use the resulting interface to create a property group. 

ISharedPropertyGroup has several methods that can be used to share state among multiple objects in a server process. See ISharedPropertyGroup in the MTS documentation for a list of methods. 

By using shared property groups, you eliminate name collisions because they establish unique name spaces for the shared properties they contain. The Shared Property Manager also implements locks and semaphores to protect shared properties from simultaneous access, which could result in lost updates and could leave the properties in an unpredictable state.

Note: Only objects running in the same process can share properties. If you want instances of different components to share properties, you have to install the components in the same MTS package. Because there is a risk that administrators will move components from one package to another, it's safest to limit the use of a shared property group to instances of components that are defined in the same DLL.
 

 

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!