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.