public virtual void Close(int reason = AegisResult.Ok)
{
try
{
// 작업 중 다른 이벤트가 처리되지 못하도록 Clear까지 lock을 걸어야 한다.
lock (this)
{
if (Socket == null)
return;
Socket.LingerState = new LingerOption(true, 3);
Socket.Close();
Socket = null;
Inactivated?.Invoke(this);
SpinWorker.Dispatch(() =>
{
EventClose?.Invoke(new IOEventResult(this, IOEventType.Close, reason));
});
_method.Clear();
}
}
catch (Exception e)
{
Logger.Err(LogMask.Aegis, e.ToString());
}
}