AcceptTcpClient() while(!Disposing) .
I, Stop() TcpListener Disposing true; :
public class Server : IDisposable
{
private TcpListener _tcpListener;
private bool _isDisposing;
public void Start()
{
(new Thread(new ThreadStart(ListenForClients))).Start();
}
private void ListenForClients()
{
this._tcpListener = new TcpListener(System.Net.IPAddress.Any, this.ListenPort);
this._tcpListener.Start();
while (!_isDisposing)
{
TcpClient client = this._tcpListener.AcceptTcpClient();
if (client == null) continue;
}
}
public void Dispose()
{
this._isDisposing = true;
this._tcpListener.Stop();
}
}
, ...
, AcceptTcpClient() .
Thread (Start() function).