From 3e36e84e2e9f5c2ea79c3274172be68f27174d13 Mon Sep 17 00:00:00 2001 From: Alexey Zimarev Date: Fri, 7 Jan 2022 23:20:18 +0100 Subject: [PATCH] Wrap CancellationTokenSource in using #1685 --- src/RestSharp/RestClient.Async.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/RestSharp/RestClient.Async.cs b/src/RestSharp/RestClient.Async.cs index 49ac4c773..8b24f8775 100644 --- a/src/RestSharp/RestClient.Async.cs +++ b/src/RestSharp/RestClient.Async.cs @@ -55,9 +55,9 @@ async Task ExecuteInternal(RestRequest request, CancellationTo message.Headers.Host = Options.BaseHost; message.Headers.CacheControl = Options.CachePolicy; - var timeoutCts = new CancellationTokenSource(request.Timeout > 0 ? request.Timeout : int.MaxValue); - var cts = CancellationTokenSource.CreateLinkedTokenSource(timeoutCts.Token, cancellationToken); - var ct = cts.Token; + using var timeoutCts = new CancellationTokenSource(request.Timeout > 0 ? request.Timeout : int.MaxValue); + using var cts = CancellationTokenSource.CreateLinkedTokenSource(timeoutCts.Token, cancellationToken); + var ct = cts.Token; try { var headers = new RequestHeaders()