ScanDeviceManager Connect
Connects to a device. The calling thread will be blocked, until a connection is established or fails.
public void Connect(string deviceUniqueName) |
Return value
void |
Parameters
string | deviceUniqueName | Unique name of the device |
Exceptions
DeviceNotFoundException | Throws when the device with the given name is not found |
DeviceAlreadyInUseException | Throws when the device is already connected to another client |
DeviceCommunicationFailureException | Throws when the communication with the device is failed |
DeviceFailureException | Throws when the device failed to connect due to unknown reason |
Example
Copy
try
{
scanDeviceManager.Connect((comboBox_Devices.SelectedItem as Device).DeviceUniqueName);
}
#region Exceptions
catch (DeviceNotFoundException)
{
MessageBox.Show("Device could not be found", "Custom Canvas");
}
catch (DeviceAlreadyInUseException)
{
MessageBox.Show("Device is already in use. Please try after sometime", "Custom Canvas");
}
catch (DeviceCommunicationFailureException ex3)
{
MessageBox.Show("Communication with the device failed. Please try after sometime.\nMessage: " + ex3.DeviceMessage, "Custom Canvas");
}
catch (DeviceFailureException ex4)
{
MessageBox.Show("Failed to connect with the device.\nMessage: " + ex4.DeviceMessage, "Custom Canvas");
}
#endregion