using Microsoft.Net.Http.Headers;
using System.Diagnostics;
using System.Threading.Tasks;
var tokenSource2 = new CancellationTokenSource();
CancellationToken ct = tokenSource2.Token;
var task = Task.Run(() =>
ct.ThrowIfCancellationRequested();
if (ct.IsCancellationRequested)
ct.ThrowIfCancellationRequested();
catch (OperationCanceledException e)
Console.WriteLine($"{nameof(OperationCanceledException)} thrown with message: {e.Message}");