private void SendingPowerToSHES() { while (true) { try { lock (lockObject) { if (Consumers.Count > 0) { proxy.SendConsumerPower(Consumers); } } } catch (Exception) { Console.WriteLine("SHES is not avaiable"); proxy = new ChannelFactory <ISHESContract>(new NetTcpBinding(), new EndpointAddress("net.tcp://localhost:5000/SHES")).CreateChannel(); Thread.Sleep(1000); } Thread.Sleep(1000); } }
private void SendingPowerToSHES() { while (true) { try { lock (lockObject) { this.Dispatcher.Invoke((Action)(() => { if ((bool)chargeCB.IsChecked) { proxy.SendEVPower(vehicle); } else { proxy.SendEVPower(new EVehicle() { Power = 0 }); } })); } } catch (Exception) { Console.WriteLine("SHES is not avaiable"); proxy = new ChannelFactory <ISHESContract>(new NetTcpBinding(), new EndpointAddress("net.tcp://localhost:5000/SHES")).CreateChannel(); Thread.Sleep(1000); } Thread.Sleep(1000); } }