private async void ControlStationService_terminalConnected(IPHostEntry terminal) { newsStatusDataTable.Rows.Add(terminal.HostName, "connected..."); using (var clt = new TerminalServiceClient(new BasicHttpBinding(), new EndpointAddress(new UriBuilder("http", terminal.AddressList[0].ToString(), 5678).Uri))) { await clt.SetNewsAsync(newsChangeTextBox.Rtf); newsStatusDataTable.Rows.Find(terminal.HostName).SetField <string>("status", "done!"); } }
private async void newsChangeButton_Click(object sender, EventArgs e) { var news = newsChangeTextBox.Rtf; foreach (var row in newsStatusDataTable.Rows.Cast <DataRow>()) { row.SetField("status", "awaiting..."); } foreach (var trm in ControlStationService.terminals) { try { using (var clt = new TerminalServiceClient(new BasicHttpBinding(), new EndpointAddress(new UriBuilder("http", trm.AddressList[0].ToString(), 5678).Uri))) { await clt.SetNewsAsync(news); newsStatusDataTable.Rows.Find(trm.HostName).SetField <string>("status", "done!"); } } catch (Exception ex) { newsStatusDataTable.Rows.Find(trm.HostName).SetField <string>("status", ex.GetType().Name); } } }