InstanceDestruction event is fired whenever the
Application Runtime Environment destroys an instance of a script.
InstanceDestruction event is provided for developers to execute logic which is needed immediately before an instance is unloaded. Because scripts can end in any number of locations due to
Forward usage, application unloading, and by unexpected errors causing script crashes, the
InstanceDestruction script is an ideal way to ensure that any resources that need to be cleaned deterministically occur. A good analogy to help understand
InstanceDestruction is the
try/catch/finally pattern, where scripts are the code in the
try block, application crashes occur in the
catch block, and the
finally block corresponds to the code in the
InstanceDestruction event provides the
ErrorText event parameters to indicate under what circumstances did the script instance unload.
InstanceDestruction event is completely optional.
InstanceDestruction occurs whenever a script is ended with
Forward, abnormal exit due to unhandled exception or script error, or if the application server is unloading the application. Refer to
ErrorCode regarding more information on specific reasons for script instance termination.
InstanceDestruction event handler has up to 30 seconds to finish, by default. This amount is configurable on an application server-wide basis.
If an application is being unloaded due to the
application server service stopping or if the application is being uninstalled, the script has excecution stopped immediately and then the
InstanceDestruction event handler is executed.
|Parameter Name||.NET Type||Description|
|ErrorText||An error message describing the specific reason that the application ended.|