private void ConnectCallback(IAsyncResult ar)
        {
            try
            {
                _tcpConnection.FinalizeConnect(ar);
                _connectedToServer = true;
                _connectDone.Set();
                _connectFinalized.Set();
            }
            catch (Exception e)
            {
                if (e is SocketException se && se.SocketErrorCode == SocketError.ConnectionRefused)
                {
                    _connectDone.Set();
                    return;
                }

                ConnectionError.PrintUnexpectedConnectionErrorDetails(e);
                throw;
            }
        }