Stonefield Query calls the Application.Shutdown script when the application terminates. This can be used to perform any desired cleanup tasks.

Parameters
A reference to the Stonefield Query Application object.

Return Value
Any value (Stonefield Query ignores the return value).

Example
Suppose the Application.AfterSetup script instantiates a COM object and adds it as a property of the Application object. When Stonefield Query shuts down, you may need to call a method of the COM object to clean up after itself or release resources. The following script in Application.Shutdown does this.

Visual FoxPro

lparameters toApplication as SQApplication
toApplication.oCOMObject.CleanupResources()
toApplication.oCOMObject = .NULL.

VBScript

function Main(Application)
Application.oCOMObject.CleanupResources()
Application.oCOMObject = NULL
end function

JavaScript

function Main(Application) {
Application.oCOMObject.CleanupResources() ;
Application.oCOMObject = NULL ;
}

C#

Please note that the method in this script must be named Application_Shutdown.

For information on dealing with custom SFQApplication Properties in C# and VB.NET please see the Script Languages topic

public static void Application_Shutdown(SFQApplication sfqApplication)
{	
  object oCOMObject = sfqApplication.GetProperty("oCOMObject");
  ReflectionService.CallMethod(oCOMObject, "CleanupResources", null);
  sfqApplication.SetProperty("oCOMObject", null);
}

VB.NET

Please note that the method in this script must be named Application_Shutdown.

For information on dealing with custom SFQApplication Properties in C# and VB.NET please see the Script Languages topic

public shared function Application_Shutdown(sfqApplication as SFQApplication) as Boolean
  Dim oCOMObject as Object = sfqApplication.GetProperty("oCOMObject")
  ReflectionService.CallMethod(oCOMObject, "CleanupResources", Nothing)
  sfqApplication.SetProperty("oCOMObject", Nothing)
  Return True
End Function

See also

Application.AfterSetup | Scripts

© Stonefield Software Inc., 2023 • Updated: 06/06/16
Comment or report problem with topic