public override async ValueTask DetachAsync(CancellationToken cancellationToken = default)
    {
        try
        {
            await _database.Xdr.WriteAsync(IscCodes.op_service_detach, cancellationToken).ConfigureAwait(false);

            await _database.Xdr.WriteAsync(Handle, cancellationToken).ConfigureAwait(false);

            await _database.Xdr.WriteAsync(IscCodes.op_disconnect, cancellationToken).ConfigureAwait(false);

            await _database.Xdr.FlushAsync(cancellationToken).ConfigureAwait(false);

            Handle = 0;
        }
        catch (IOException ex)
        {
            throw IscException.ForIOException(ex);
        }
        finally
        {
            try
            {
                await _connection.DisconnectAsync(cancellationToken).ConfigureAwait(false);
            }
            catch (IOException ex)
            {
                throw IscException.ForIOException(ex);
            }
            finally
            {
                _database   = null;
                _connection = null;
            }
        }
    }
Example #2
0
 public ValueTask CloseConnectionAsync(CancellationToken cancellationToken = default)
 {
     return(_connection.DisconnectAsync(cancellationToken));
 }