private void cierraServer() { My_SQL mysql = new My_SQL(); int nq = mysql.hazNoConsulta("update usuarios set connected='0', playing='0'"); if (hiloEscucha != null) { hiloEscucha.Abort(); hiloRegenera.Abort(); servidor.Stop(); for (int i = 0; i < ctes; i++) { if (clientes[i] != null) { clientes[i].cierraCte(""); hilosCte[i].Abort(); } } } if (ctesUDP != null) { ctesUDP.cierraServidor(); while (!ctesUDP.cerrado) { Thread.Sleep(10); } ctesUDP.closeServer(); ctesUDP = null; } if (hiloUDP != null) { hiloUDP.Abort(); } }
internal EscuchaCte(TcpClient c, Label[] l, int n, HiloComsUDP u) { cte = c; flujo = c.GetStream(); nCte = n; lCte = l; ctesUDP = u; }
private void btnIniciar_Click(object sender, EventArgs e) { My_SQL mysql = new My_SQL(); int nq = mysql.hazNoConsulta("update usuarios set connected='0', playing='0'"); btnIniciar.Enabled = false; btnDetener.Enabled = true; ctesUDP = new HiloComsUDP(); hiloUDP = new Thread(new ThreadStart(ctesUDP.startserver)); hiloUDP.Start(); hiloEscucha = new Thread(new ThreadStart(this.hilo_Escucha)); hiloEscucha.Start(); hiloRegenera = new Thread(new ThreadStart(this.hilo_Regenera)); hiloRegenera.Start(); }