Exemplo n.º 1
0
        /// <summary>
        /// Dispose all used resources
        /// </summary>
        public async ValueTask DisposeAsync()
        {
            await client.DisposeAsync();

            await input.DisposeAsync();

            await output.DisposeAsync();
        }
Exemplo n.º 2
0
        private async Task <Result <AggregateException> > _executeNoTransformations()
        {
            if (_inputFunc == null || _outputFunc == null)
            {
                throw new InvalidOperationException(
                          "An input source and an output sink must both be set with SetInput/SetOutput respectively.");
            }

            var server = new AnonymousPipeServerStream(PipeDirection.Out, HandleInheritability.None, BufferSize);
            var client = new AnonymousPipeClientStream(server.GetClientHandleAsString());

            var inputTask = Task.Run(async() =>
            {
                try
                {
                    return(await _inputFunc(server));
                }
                finally
                {
                    await server.DisposeAsync();
                }
            });

            var outputTask = Task.Run(async() =>
            {
                try
                {
                    return(await _outputFunc(client));
                }
                finally
                {
                    await client.DisposeAsync();
                }
            });

            // server.DisposeLocalCopyOfClientHandle();

            return((await Task.WhenAll(inputTask, outputTask)).Combine());
        }