Answers for "cancellationtoken.linkedtokensource c# example"

C#
0

cancellationtoken.linkedtokensource c# example

private async Task<RestResponse> SendInternalAsync(HttpRequestMessage request, CancellationToken cancelToken, bool headerOnly)
        {
            cancelToken = CancellationTokenSource.CreateLinkedTokenSource(_cancelToken, cancelToken).Token;
            HttpResponseMessage response = await _client.SendAsync(request, cancelToken).ConfigureAwait(false);
             
            var headers = response.Headers.ToDictionary(x => x.Key, x => x.Value.FirstOrDefault(), StringComparer.OrdinalIgnoreCase);
            var stream = !headerOnly ? await response.Content.ReadAsStreamAsync().ConfigureAwait(false) : null;
 
            return new RestResponse(response.StatusCode, headers, stream);
        }
Posted by: Guest on February-10-2021

C# Answers by Framework

Browse Popular Code Answers by Language