Ver Mensaje Individual
  #8 (permalink)  
Antiguo 02/01/2008, 08:02
chcma
 
Fecha de Ingreso: junio-2003
Ubicación: Asturias
Mensajes: 2.429
Antigüedad: 21 años, 9 meses
Puntos: 7
Re: C# Clase con Eventos, error actualizando control.

Perdona Peterpay, pero... no entiendo como dices... Si pudieras explicarmelo un poco más detalladamente te lo agradecería muchísimo, de verdad.

Actualmente tengo en mi clase lo siguiente:
Código:
public delegate void EventoNuevaConexion(string txtIpCliente, int puertoCliente);
public event EventoNuevaConexion NuevaConexion;



//EN OTRA PARTE DEL CODIGO ES CUANDO LANZO EL EVENTO:
NuevaConexion("132.0.0.1", 1880);


Y en el Formulario tengo:
Código:
private void btnIniciar_Click(object sender, EventArgs e)
{
       objHeviaServer.NuevaConexion += new HeviaServerXml.ClsServidor.EventoNuevaConexion(objHeviaServer_NuevaConexion);
}







        private delegate void DelegadoNuevaConexion(string txtIpCliente, int puertoCliente);
        private void objHeviaServer_NuevaConexion(string txtIpCliente, int puertoCliente)
        {
            DelegadoNuevaConexion delegadoNuevaConexion = new DelegadoNuevaConexion(NuevaConexionCliente);
            if (txtEventos.InvokeRequired)
                txtEventos.Invoke(delegadoNuevaConexion, new object[] { txtIpCliente, puertoCliente });
            else
            {
                txtEventos.Text += "[NUEVA CONEXION] " + txtIpCliente + ":" + puertoCliente;
                txtEventos.Text += Environment.NewLine;
            }
        }
        private void NuevaConexionCliente(string txtIpCliente, int puertoCliente)
        {
            txtEventos.Text += "[NUEVA CONEXION] " + txtIpCliente + ":" + puertoCliente;
            txtEventos.Text += Environment.NewLine;
        }
Si me puedes comentar como reducir el código del Formulario te lo agradecería.

Saludos.
__________________
Charlie.