public async ValueTask DisposeAsync() { if (Interlocked.Exchange(ref _isDisposed, 1) != 0) { return; } _eventRegister.Register(new ReaderDisposed(_correlationId, this)); await _channel.DisposeAsync(); }
public async ValueTask DisposeAsync() { if (Interlocked.Exchange(ref _isDisposed, 1) != 0) { return; } _eventRegister.Register(new ReaderDisposed(_correlationId, this)); await _channel.ClosedByClient(CancellationToken.None).ConfigureAwait(false); await _channel.DisposeAsync().ConfigureAwait(false); }
internal async ValueTask SetChannel(IReaderChannel channel) { if (_isDisposed != 0) { await channel.DisposeAsync().ConfigureAwait(false); return; } var oldChannel = _channel; _channel = channel; if (oldChannel != null) { await oldChannel.DisposeAsync().ConfigureAwait(false); } }