Skip to content

Commit fa9d37d

Browse files
Manually backport #1206
(cherry picked from commit f90b9ca)
1 parent 6b1a06b commit fa9d37d

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

projects/RabbitMQ.Client/client/impl/SocketFrameHandler.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ internal static class TaskExtensions
4747
{
4848
public static async Task TimeoutAfter(this Task task, TimeSpan timeout)
4949
{
50+
#if NET6_0_OR_GREATER
51+
await task.WaitAsync(timeout).ConfigureAwait(false);
52+
#else
5053
if (task == await Task.WhenAny(task, Task.Delay(timeout)).ConfigureAwait(false))
5154
{
5255
await task.ConfigureAwait(false);
@@ -56,6 +59,7 @@ public static async Task TimeoutAfter(this Task task, TimeSpan timeout)
5659
Task supressErrorTask = task.ContinueWith((t, s) => t.Exception.Handle(e => true), null, CancellationToken.None, TaskContinuationOptions.OnlyOnFaulted | TaskContinuationOptions.ExecuteSynchronously, TaskScheduler.Default);
5760
throw new TimeoutException();
5861
}
62+
#endif
5963
}
6064
}
6165

0 commit comments

Comments
 (0)