public IWritableChannel MakeWriteableChannel(Stream stream) { if (!stream.CanWrite) { throw new InvalidOperationException(); } var channel = new MemoryPoolChannel(_pool); channel.CopyToAsync(stream).ContinueWith((task) => { channel.CompleteReading(); }); return(channel); }
public IWritableChannel CreateWritableChannel(Stream stream) { if (!stream.CanWrite) { throw new InvalidOperationException(); } var channel = new MemoryPoolChannel(_pool); channel.CopyToAsync(stream).ContinueWith((task, state) => { ((Stream)state).Dispose(); }, stream); return(channel); }