Destroy

 (Available in 01 TS COM - TS_COM_ServerInfo)

Purpose

CALLBACK: It is adviced to use 'oObject:Axit()'

Syntax

// See the documentation for the 'Axit' method.
oSomeClass:Axit( ) 

Description

This is where the application releases all refered to dynamicly allocated resources ( ARRAY, OBJECT, STRING ), and where all staticaly allocated memory is freed.

Note: Do not execute the 'Destroy()' method directly, it is adviced to call the 'Axit()' method when destruction of the object is needed this method of destruction is optimized for speed and guaranties that the 'Destroy()' method is only called once.

Note: The designer of the class should be aware of the fact that the 'Destroy()' method can be called multiple times.

Example

METHOD Destroy( ) CLASS SomeClass
// Let it be known that we are destroying the object
   SELF:IsInDestroy:=TRUE 
// Do the destructive work
   ... 
// All work should be done before calling SUPER
   SUPER:Destroy( ) 
RETURN NIL

Source

METHOD Destroy( ) CLASS TS_ServerInfo
LOCAL oServerInfo AS TS_ServerInfo
   TSTrace Enter
   IF SELF:_COMGlobalData<>NULL_OBJECT .AND. SELF:_SuperGlobalData ; ...
  ... <>NULL_OBJECT
      SELF:_ObjectStat1:=_OR( SELF:_ObjectStat1 ; ...
     ... , TS_OBJSTAT1_INDESTROY )
      oServerInfo:=SELF:_COMGlobalData:_ServerInfoServerInfoObject
      IF oServerInfo==SELF
         SELF:_COMGlobalData:_ServerInfoServerInfoObject ; ...
        ... :=NULL_OBJECT
         oServerInfo:=NULL_OBJECT
      END
      IF LONGINT( SELF:_COMGlobalData:_ServerInfoInstanceCount  ; ...
     ... )<0L
         TSTrace Warning "LONGINT(SELF:_COMGlobalData:_ServerInfoInstanceCount)<0L"
      END
      InterlockedDecrement( SELF:_COMGlobalData:_ServerInfoInstanceCount  ; ...
     ... )
   END
   SELF:_SuperGlobalData:=NULL_OBJECT
   SELF:_COMGlobalData:=NULL_OBJECT
   SUPER:Destroy( )
   TSTrace Leave DESTROY
RETURN NIL