Close Method (Server object)



Closes a connection to a Server. Typically done when no more work will be done on the Server and objects retrieved from the server are no longer referenced.



The Close method syntax has these parts:




An object expression that evaluates to a Server object.


When this method is called, the OnClose event is fired.

Closing a server can allow the PI-SDK to free up resources when access to the server is no longer needed. The Close method is also used when a program already connected to a server wishes to connect as a different user. Attempting to open a server that is already open under a different connection string generates an error. Instead the program should call Close before the second open attempt.


In PI-SDK versions prior to 1.4, when Close is called, objects that directly communicate with the server (connected objects), become disconnected and further calls that require server access will return pseDISCONNECTEDOBJECT.  See the discussion on Disconnected Objects under See Also for recommended handling of this situation.


Trappable Errors

In addition to generic errors (such as Out of Memory), the following errors may occur:




The server was already closed.


Unable to close the underlying session. More detail is provided in the description field of the raised error.

Enabling Operational Intelligence