Disconnect Method

Public Sub Disconnect()

Summary

This method closes the connection to the ETH32 device and cleans up all of the resources within the API that were used for the connection. After this method returns, most of the methods and properties of the object won't be able to be successfully used until another connection has been formed using the Connect Method.

Parameters

This method does not have any parameters.

Return Value

This method does not return a value.

Remarks

You should be careful to always call this method when you are finished using the device. The device has a limited number of connections it can support and if you do not disconnect and your application continues executing, you will continue using one of those connections. If you fail to call this method, your connections will remain open potentially until your application terminates.

In this Visual Basic 6 class, you also must be particularly careful to call this method when your application is shutting down. If your application is structured to exit when the last form has been closed (as opposed to using an End statement), then any open ETH32 connection will prevent your application from actually closing. This is because each connected Eth32 class uses a hidden form to assist in processing events from the device. If Disconnect hasn't been called, this form will still exist, preventing the application from exiting. Because the form is hidden, you may not even realize your application is still running unless you look closely in the task manager.

To summarize: Always call Disconnect. Don't depend on application cleanup to do it for you.

It is a good idea to put code similar to the following in the Form_Unload event of your main form. This code assumes that your object variable name is dev:

' When this form unloads, make sure the connection is closed, otherwise
' it will keep the application running.
If Not (dev Is Nothing) Then
	' dev is at least instantiated
	If dev.Connected Then
		dev.Disconnect
	End If
End If

See Also

Connect Method, Connected Property