private void ChannelControl_ToggleStateClicked(object sender, ChannelToggledEventArgs e) { using (var relayController = new RelayController()) { relayController.ConnectDevice(e.DeviceInfo); var control = sender as ChannelInfoControl; control.ChannelInfo = relayController.ToggleChannel(e.DeviceInfo, e.ChannelInfo.Index); } }