private void CloseSocket() { if (_socket == null) return; lock (_socketShutdownAndCloseLock) { var socket = _socket; if (socket != null) { _socket = null; socket.Dispose(); } } }