From 5198c976d0b8d13502fdae6a31625884944a72da Mon Sep 17 00:00:00 2001 From: Bruce Wayne Date: Tue, 10 Aug 2021 19:51:11 +0800 Subject: [PATCH] fix: Ignore Exceptions in PipeReader.CopyToAsync --- Pipelines.Extensions/PipelinesExtensions.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Pipelines.Extensions/PipelinesExtensions.cs b/Pipelines.Extensions/PipelinesExtensions.cs index 3ee2744..9eea342 100644 --- a/Pipelines.Extensions/PipelinesExtensions.cs +++ b/Pipelines.Extensions/PipelinesExtensions.cs @@ -15,7 +15,11 @@ public static async ValueTask LinkToAsync(this IDuplexPipe pipe1, IDuplexPipe pi var a = pipe1.Input.CopyToAsync(pipe2.Output, token); var b = pipe2.Input.CopyToAsync(pipe1.Output, token); - await Task.WhenAny(a, b); // TODO: Use WhenAll? .NET6.0 + var task = await Task.WhenAny(a, b); + if (task.IsCompletedSuccessfully) + { + await Task.WhenAll(a, b); + } } [MethodImpl(MethodImplOptions.AggressiveInlining)]