private void button1_Click(object sender, EventArgs e) { if (SHost == null) { SServ = new ShopService(); SServ.mail = tbMail.Text; SServ.pass = tbPass.Text; SHost = new ServiceHost(SServ); SHost.Open(); WServ = new WebService(); WServ.shopSrv = SServ; WHost = new ServiceHost(WServ); WHost.Open(); label1.Text = "Serviço Aberto"; button1.Text = "Fechar Serviço"; } else { SHost.Close(); SHost = null; SServ = null; label1.Text = "Serviço Fechado"; button1.Text = "Abrir Serviço"; } }
private void ShopServer_FormClosing(object sender, FormClosingEventArgs e) { if (SHost != null) { SHost.Close(); SHost = null; SServ = null; } }