# Runtime Client C# API

The topics in this section provide information about how to use the Remote C# API to setup a runtime client.

## ViDi2.Runtime.Remote.Client.Http.HttpControl

To connect to a remote service, you must first instantiate a ViDi2.Runtime.Remote.Client.Control, and then connect to the service.

Methods
Control(IImageFactory imageFactory) | Creates a client runtime control with the given IImageFactory, which will be used to load images received from the service. Unlike a local control, there is no need to pass in a LibraryAccess object – the remote control automatically creates and uses a remote LibraryAccess object. In general, a remote control can be used transparently wherever you would normally use a local control.
void Connect(string uri) | Connects to the given uri, where the uri corresponds to a valid VisionPro Deep Learning service. The uri should be in the form "http://<ip>:<port>" where <ip> and <port> correspond to your VisionPro Deep Learning service. This should correspond to the --http-address=http://address:port command line parameter setting. This method may throw a TimeoutException if the service doesn't respond. It may also throw exceptions if the control is already connected to a service, or if the service is a training Training is the process that your tool, which is a neural network, is learning about the features (pixels) based on the labels you made. For example, a tool will learn the defect/normal pixels in each image based on the defect/normal labels you drew. The goal of the tool Training is learning enough to give the correct inspection results of whether an unseen image is defective or not. The key to training is to ensure that you include all possible variations within your training set, and that your images are accurately labeled. Training times vary by the application, tool setup and the GPU in the PC being used to train the network. service while the control is a runtime control. If connection fails in this way, the control should be disposed, and re-connection should be attempted with a new control. The number of instantiated controls is not limited in a process, however, each process is only allowed to connect one control to each specific service running.
Properties
string ServiceUri | The uri to which the control is currently connected, or null if the control isn't connected to a service.
bool IsConnected | Returns true after Connect has been called successfully.
IServiceInfos ServiceInfos | Returns information about the service to which the control is connected. Available after Connect has been called successfully.
IConnectionMonitor ConnectionMonitor | Returns an object that periodically pings the service, starting after Connect has been called successfully. The events published by this object allow subscribers to monitor the control's connection with the service.

## ViDi2.Remote.Client.IServiceInfos

Contains information about a remote service and its environment.

Properties
string OS | The operating system on which the service is running. Note: See the following Microsoft Developer Network topic for more information about formatting: OperatingSystem.VersionString Property
LibraryTypeEnum ServiceType | The service type, Training or Runtime.

## ViDi2.Remote.Connection.IConnectMonitor

Periodically pings a service to make sure the client has not disconnected. Once started, this runs in the background until it is disposed.

Methods
void Start() | Allows the connection monitor to start pinging a service. This is called automatically when a remote control finishes connecting to a service.
void Dispose() | Waits for the current ping to complete (or timeout), then stops the background task.
Property
TimeSpan DefaultWaitTime | The amount of time to wait between consecutive pings.
TimeSpan DisconnectedWaitTime | The amount of time to wait after an unsuccessful ping before trying again.
bool IsRunning | True if the connection monitor is periodically pinging the service.
Events
EventHandler<string> ServerTimedOut | Raised when the service fails to respond to a ping. The argument passed to the EventHandler is the service's uri.
EventHandler<string> ServerConnectionRecovered | Raised when the service successfully responds to a ping after failing to respond at least once. The argument passed to the EventHandler is the service's uri.
EventHandler<string> ServerHasChanged | Raised when the control connects to a different service. The argument passed to the EventHandler is the new service's uri.