private void btnPing_Click(object sender, EventArgs e) { DemoServiceClient.DemoServiceClient dsc; DemoServiceSesAClient.DemoSvcSesAClient dssc; DemoServiceSesNAClient.DemoSvcSesNAClient dssnac; switch (cBoxClientList.SelectedItem.ToString()) { case "DemoServiceClient": dsc = new DemoServiceClient.DemoServiceClient(); tbPing.Text = dsc.Ping(); dsc.Close(); break; case "DemoServiceSesAClient": dssc = new DemoServiceSesAClient.DemoSvcSesAClient(); tbPing.Text = dssc.Ping(); dssc.Close(); break; case "DemoServiceSesNAClient": dssnac = new DemoServiceSesNAClient.DemoSvcSesNAClient(); tbPing.Text = dssnac.Ping(); dssnac.Close(); break; default: MessageBox.Show("No Client!"); break; } }
public static void CallPing() { // DemoServiceClient.DemoServiceClient demo = new DemoServiceClient.DemoServiceClient(m_SelectedEP); DemoServiceClient.DemoServiceClient dsc = null; DemoServiceSesAClient.DemoSvcSesAClient dssc = null; DemoServiceSesNAClient.DemoSvcSesNAClient dssnac = null; string strMessage = ""; if (m_SelectedClient.Equals("DemoServiceClient")) { while (true) { dsc = new DemoServiceClient.DemoServiceClient(m_SelectedEP); try { strMessage = dsc.Ping(); } catch (Exception ex) { //MessageBox.Show(ex.Message); } finally { } } } if (m_SelectedClient.Equals("DemoServiceSesAClient")) { while (true) { dssc = new DemoServiceSesAClient.DemoSvcSesAClient(m_SelectedEP); try { strMessage = dssc.Ping(); } catch (Exception ex) { //MessageBox.Show(ex.Message); } finally { } } } if (m_SelectedClient.Equals("DemoServiceSesNAClient")) { while (true) { dssnac = new DemoServiceSesNAClient.DemoSvcSesNAClient(m_SelectedEP); try { strMessage = dssnac.Ping(); } catch (Exception ex) { //MessageBox.Show(ex.Message); } finally { } } } //if (dsc != null) // dsc.Close(); //if (dssc != null) // dssc.Close(); //if (dssnac != null) // dssnac.Close(); }