V
vitagoni
I'm doing the next.
public void CloseListener()
{
listener.Stop();
listen.Abort();
listen.Join();
if (sock != null)
{
try { sock.Close(); }
catch (Exception) { }
}
return;
}
public bool Listen(int port)
{
listener = new TcpListener(port);
if (listener == null) return false;
listener.Start();
listen = new Thread(new ThreadStart);
if (listen != null)
{
listen.Start(mess);
return true;
}
return false;
}
public void Listener()
{
try
{
sock = listener.AcceptSocket();
}
catch (Exception ex)
{
throw(ex);
}
......
It is called from main form, which controls all that..
But when I close the main form and invoke CloseListener then application
hangs on at sock = listener.AcceptSocket();
Tell me how to stop listener from outside of the working thread..
public void CloseListener()
{
listener.Stop();
listen.Abort();
listen.Join();
if (sock != null)
{
try { sock.Close(); }
catch (Exception) { }
}
return;
}
public bool Listen(int port)
{
listener = new TcpListener(port);
if (listener == null) return false;
listener.Start();
listen = new Thread(new ThreadStart);
if (listen != null)
{
listen.Start(mess);
return true;
}
return false;
}
public void Listener()
{
try
{
sock = listener.AcceptSocket();
}
catch (Exception ex)
{
throw(ex);
}
......
It is called from main form, which controls all that..
But when I close the main form and invoke CloseListener then application
hangs on at sock = listener.AcceptSocket();
Tell me how to stop listener from outside of the working thread..