Skip to content

Commit

Permalink
Update projects/RabbitMQ.Client/client/TaskExtensions.cs
Browse files Browse the repository at this point in the history
Co-authored-by: Paulo Morgado <470455+paulomorgado@users.noreply.github.com>
  • Loading branch information
lukebakken and paulomorgado authored Nov 19, 2023
1 parent 0d13a2c commit 90b72b9
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions projects/RabbitMQ.Client/client/TaskExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,21 @@ static async Task TimeoutAfterImplement(Task task, TimeSpan timeout)
#endif
}

public static async ValueTask TimeoutAfter(this ValueTask task, TimeSpan timeout)
public static ValueTask TimeoutAfter(this ValueTask task, TimeSpan timeout)
{
if (false == task.IsCompletedSuccessfully)
if (task.IsCompletedSuccessfully)
{
Task actualTask = task.AsTask();
return task;
}

#if NET6_0_OR_GREATER
await actualTask.WaitAsync(timeout)
.ConfigureAwait(false);
return actualTask.WaitAsync(timeout);
#else
return TimeoutAfterImplement(task, timeout);

assync static ValueTask TimeoutAfterImpl(ValueTask task, TimeSpan timeout)

Check failure on line 90 in projects/RabbitMQ.Client/client/TaskExtensions.cs

View workflow job for this annotation

GitHub Actions / call-build-test / build, unit test on ubuntu-latest

; expected

Check failure on line 90 in projects/RabbitMQ.Client/client/TaskExtensions.cs

View workflow job for this annotation

GitHub Actions / call-build-test / build, unit test on ubuntu-latest

; expected
{
Task actualTask = task.AsTask();
if (actualTask == await Task.WhenAny(actualTask, Task.Delay(timeout)).ConfigureAwait(false))
{
await actualTask.ConfigureAwait(false);
Expand All @@ -98,6 +104,7 @@ await actualTask.WaitAsync(timeout)
scheduler: TaskScheduler.Default);
throw new TimeoutException();
}
}
#endif
}
}
Expand Down

0 comments on commit 90b72b9

Please sign in to comment.