public void Dispose()
        {
            if (!_disposed)
            {
                _disposed = true;

                if (TransactionCount > 0)
                {
                    throw IscException.ForErrorCodeIntParam(IscCodes.isc_open_trans, TransactionCount);
                }

                try
                {
                    CloseEventManager();

                    var detach = _handle != -1;
                    if (detach)
                    {
                        XdrStream.Write(IscCodes.op_detach);
                        XdrStream.Write(_handle);
                    }
                    XdrStream.Write(IscCodes.op_disconnect);
                    XdrStream.Flush();
                    if (detach)
                    {
                        ReadResponse();
                    }

                    CloseConnection();

#warning Here
                    _xdrStream?.Dispose();
                }
                catch (IOException ex)
                {
                    try
                    {
                        CloseConnection();
                    }
                    catch (IOException ex2)
                    {
                        throw IscException.ForErrorCode(IscCodes.isc_network_error, ex2);
                    }
                    throw IscException.ForErrorCode(IscCodes.isc_network_error, ex);
                }
                finally
                {
                    _xdrStream        = null;
                    _connection       = null;
                    _charset          = null;
                    _eventManager     = null;
                    _serverVersion    = null;
                    _dialect          = 0;
                    _handle           = -1;
                    _packetSize       = 0;
                    _warningMessage   = null;
                    _transactionCount = 0;
                }
            }
        }
        public virtual void Detach()
        {
            lock (SyncObject)
            {
                if (TransactionCount > 0)
                {
                    throw IscException.ForErrorCodeIntParam(IscCodes.isc_open_trans, TransactionCount);
                }

                try
                {
                    if (_handle != 0)
                    {
                        XdrStream.Write(IscCodes.op_detach);
                        XdrStream.Write(_handle);
                    }
                    XdrStream.Write(IscCodes.op_disconnect);
                    XdrStream.Flush();

                    // Close the Event Manager
                    CloseEventManager();

                    // Disconnect
                    CloseConnection();

#warning Here
                    // Close Input and Output streams
                    _xdrStream?.Dispose();

                    // Clear members
                    _transactionCount = 0;
                    _handle           = 0;
                    _dialect          = 0;
                    _packetSize       = 0;
                    _xdrStream        = null;
                    _charset          = null;
                    _connection       = null;
                    _serverVersion    = null;
                }
                catch (IOException ex)
                {
                    try
                    {
                        CloseConnection();
                    }
                    catch (IOException ex2)
                    {
                        throw IscException.ForErrorCode(IscCodes.isc_network_error, ex2);
                    }

                    throw IscException.ForErrorCode(IscCodes.isc_network_error, ex);
                }
            }
        }