public void TryConnect() { try { //make sure client is connected if (client == null || !client.IsOpen) { client = new Client(System.Configuration.ConfigurationManager.AppSettings["Reactivity.Nodes.Computer.ServiceUri"]); client.DeviceUpdated += new DeviceUpdateHandler(client_DeviceUpdated); client.DeviceDeregistered += new DeviceDeregisteredHandler(client_DeviceDeregistered); client.DataReceived += new DataReceptionHandler(client_DataReceived); } } catch { if (client != null) client.Close(); client = null; return; } try { //make sure device is registered Guid device_guid = new Guid(System.Configuration.ConfigurationManager.AppSettings["Reactivity.Nodes.Computer.Device"]); if (!client.DeviceIsRegistered(device_guid)) { if (device_timer.Enabled) device_timer.Stop(); device = null; if (!client.DeviceRegister(device_guid)) return; device = client.DeviceGet(device_guid); if (device == null) return; Util.DeviceConfigurationAdapter adapter = Util.DeviceConfigurationAdapter.CreateAdapter(device.Configuration); if (adapter.Settings.ContainsKey("Interval")) device_timer.Interval = Convert.ToDouble(adapter.Settings["Interval"]); device_timer.Start(); } } catch { TryReset(); } }