public void Disconnect()
{
try
{
//this.nlock.AcquireWriterLock(Timeout.Infinite);
if (this.isDisconnected)
{
//this.nlock.ReleaseWriterLock();
return;
}
try
{
if (!disconnecting)
this.client.OnDisconnect();
disconnecting = true;
}
catch (Exception e) { Logger.ShowError(e, null); }
try
{
Logger.ShowInfo(sock.RemoteEndPoint.ToString() + " disconnected", null);
}
catch (Exception)
{
}
try { stream.Close(); }
catch (Exception) { }
//try { sock.Disconnect(true); }
try { sock.Close(); }
catch (Exception) { }
this.isDisconnected = true;
}
catch (Exception e)
{
Logger.ShowError(e, null);
try { stream.Close(); }
catch (Exception) { }
//try { sock.Disconnect(true); }
try { sock.Close(); }
catch (Exception) { }
//Logger.ShowInfo(sock.RemoteEndPoint.ToString() + " disconnected", null);
}
//this.nlock.ReleaseWriterLock();
}