Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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);
        }