Normally an Application is not started and stopped
repeatedly. The application is normally started when the DataHub instance starts, and
continues until the DataHub instance is stopped.
To shut down your application, you need to destroy the application instance. This
will cause the destructor to be called. Your clean-up code should be located in the
destructor. The Application class automatically cleans up
event handlers created using OnChange. You can detach from the
ODBC database in your destructor:
method MyODBCScript.destructor ()
{
.conn.Disconnect();
cancel (timerid);
}If you do not disconnect from the database in the destructor, the Gamma engine
will disconnect from the database when its garbage collector destroys the
ODBCConnection object.
You can destroy the application instance by calling the destroy
function. This can be triggered by a data point change or some other method. For
example:
.OnChange (#$default:kill_application, `destroy(@self));
This statement would wait for a change to the DataHub point named
default:kill_application and then destroy the application.
The application could then be restarted from the Scripting option in the DataHub Properties
window.