ThingWorx Edge .NET SDK Reference > .NET SDK: ConnectedThingClient Class
.NET SDK: ConnectedThingClient Class
The ConnectedThingClient class contains methods that manage the connection to the ThingWorx Platform and requires the ClientConfigurator to configure its properties. The life cycle of a connection is construction()start()connect()disconnect()shutdown(). This sequence is important because start() initializes the ConnectedThingClient (client) and its resources. Once started, a client can connect() or disconnect() on demand or as a function of its duty cycle. However, for it to be truly eliminated and for its resources to be released, shutdown() must be called.
* 
It is important to understand that only one ConnectedThingClient can be started at a time. If a second ConnectedThingClient tries to start or connect while the first one already exists in the started state, you will be unable to start the second instance. Instead, it will throw an exception, System.Runtime.InteropServices.ExternalException(), with the message:
Only one instance of ConnectedThingClient can be Started at a time.
Please shut down any other instances before starting this one.
For this reason, it is vital that you call shutdown() before attempting to start a new ConnectedThingClient.
A ConnectedThingClient can contain multiple instances of the VirtualThing class, as demonstrated in the Steam Sensor example.
ConnectedThingClient Methods
The following methods are available on the ConnectedThingClient class (“the client”):
bindThing(VirtualThing thing) — Binds one VirtualThing to a RemoteThing on ThingWorx Platform. The name of the platform-side thing must match the name of the VirtualThing. Once the client-side and platform-side Things are bound, data from properties, services, and events can be exchanged. The bind occurs only if the connection has been established.
As of release 5.6.4 of the .NET SDK, you can use bulk binding to bind multiple entities at once. bindThings takes a list of Things to enable you to easily create a bulk binding operation.
isConnected() — Returns true if the client is connected to an instance of the ThingWorx Platform.
isShutdown() — Returns true if the client is shut down.
shutdown() — Stops the client and the connection monitor.
* 
If you try to unbind disconnected VirtualThings, using this method, the SDK tries to release all resources used by this client. That is, all unbound Things are deleted. This behavior allows new clients to be created in the same process.
start() — Starts communications and operations for the client. Also starts the connection monitor that keeps the connection to the ThingWorx Platform alive. If the connection fails, the client tries to reconnect, waiting the number of seconds specified for the reconnect interval (ReconnectInterval property of the ClientConfigurator).
Client Objects
The way that the .NET SDK manages client objects changed in version 5.5.0. The framework supports only a single client object at a time. Keep in mind that only one ConnectedThingClient can be started at a time. The following methods operate on ALL instantiated client objects:
connect()
disconnect()
shutdown()
isConnected()
isShutdown()
isConnectionInProgress()
stopConnectionAttempt()
Was this helpful?