/// <summary> /// Completes that binary export and sets the connection back to idle state /// </summary> public void Dispose() { if (_isDisposed) { return; } if (!_isConsumed) { // Finish the current CopyData message _buf.Skip(_leftToReadInDataMsg); // Read to the end _connector.SkipUntil(BackendMessageCode.CopyDone); _connector.ReadExpecting <CommandCompleteMessage>(); _connector.ReadExpecting <ReadyForQueryMessage>(); } var connector = _connector; Cleanup(); connector.EndUserAction(); }
protected override void Dispose(bool disposing) { if (_isDisposed || !disposing) { return; } try { if (CanWrite) { Flush(); _writeBuf.EndCopyMode(); _connector.SendMessage(CopyDoneMessage.Instance); _connector.ReadExpecting <CommandCompleteMessage>(); _connector.ReadExpecting <ReadyForQueryMessage>(); } else { if (!_isConsumed) { if (_leftToReadInDataMsg > 0) { _readBuf.Skip(_leftToReadInDataMsg); } _connector.SkipUntil(BackendMessageCode.ReadyForQuery); } } } finally { var connector = _connector; Cleanup(); connector.EndUserAction(); } }