The MTSEnvironment object is instantiated within the Admin, Search, and User components of the CML application. The TableQueue object also uses the MTS object, but in a different way because its operations are not transacted. All CML objects declare the MTSEnvironment object as a New class, as in the following code:
'--- Create MTS Object context
Private MTS As New MTSEnvironment
Declaring as New defers instantiation until you later reference the object explicitly. After this statement, potential for this MTSEnvironment object exists as long as the calling object also exists, but no memory has been used for the new object. (When the calling object goes out of existence, so does the potential for the MTSEnvironment object.) If after this declaration you do not use the MTS variable, it will not be instantiated.
Note After creating an object with the New keyword, your code may at some point check whether the object is available. The mere act of checking actually instantiates the object, even if the purpose of checking is to destroy the object. If you want to destroy the object, simply set it to Nothing without checking first for its availability.
Every object in your public interface requires a separate MTS object context. This means that you cannot save steps, for example, by creating a single global MTS object context to use everywhere. The reason is that it is destroyed as soon as the creating object goes out of scope, and you will need a new object context when your object comes back into scope.
This is why all CML objects declare the MTSEnvironment object individually, in code that is run each time the calling object is created.