closeAsynch

closeAsynch(receiver: Object;
            msg:      String);

The closeAsynch method of the Connection class closes a connection to a remote application and returns immediately. When the connection is closed, the object specified in the receiver parameter is sent the name of the callback method specified in the msg parameter.

The closeAsynch method can be called when the connection is in any state.

When the closeAsynch method completes, the user-written callback method specified in the msg parameter is called.

On asynchronous calls, the state may not change immediately, and it may remain Connected (2) for a short period until JADE has rescheduled the request.

The callback method must match the signature required by the calling closeAsynch method, as follows.

closeCallback(connection: Connection);

The following example shows the use of the closeAsynch method to set the variable conlog to reference a ConnectionLog object, create the object, and initialize its properties if no such object exists.

closeAsynch_click(btn: Button input) updating;
vars
    conlog : ConnectionLog;
begin
    beginTransaction;
        conlog := ConnectionLog.firstInstance;
        if conlog = null then
            create conlog;
            conlog.numberOfListenCalls  := 0;
            conlog.numberOfOpenCalls    := 0;
            conlog.numberOfCloseCalls   := 0;
            conlog.numberOfBinaryReads  := 0;
            conlog.numberOfBinaryWrites := 0;
        endif;
    commitTransaction;
    // Closes the current connection and returns immediately.  When
    // the connection is closed, the ConnectionLog object referenced
    // by conlog is called and told to run the updateCloseCalls method.
    self.connection.closeAsynch(conlog, "updateCloseCalls");
    statusLine1.caption := "Disconnected";
end;