public MyDisposable(StreamRpcClientHandler owner, CancellationTokenSource readerCts, MessageWriter writer) { Debug.Assert(owner != null); Debug.Assert(readerCts != null || writer != null); this.owner = owner; this.readerCts = readerCts; this.writer = writer; }
/// <inheritdoc /> public void Dispose() { if (owner == null) { return; } readerCts?.Cancel(); if (owner.writer == writer) { owner.writer = null; } readerCts = null; writer = null; owner = null; }