using System.Threading.Tasks;
public static void Main()
const string test1 = "Cancellation of infinite loop. Cancel is triggered outside of loop and task creation *doesn't* include TOKEN arg.";
string headerLines = new string( '=', test1.Length );
Console.WriteLine( test1 );
Console.WriteLine( headerLines );
VESDK8021_CancellationTokenTest1_GlobalScope();
private static void VESDK8021_CancellationTokenTest1_GlobalScope()
System.Threading.CancellationTokenSource cts = new CancellationTokenSource();
Console.WriteLine("Entering infinite loop");
Task infiniteTask = new Task(() =>
if (cts.Token.IsCancellationRequested)
Console.WriteLine("Cancellation token had requested cancellation.");
Console.WriteLine($"------ Starting Infinite Task ----");
Console.WriteLine($"------ Stopping Infinite Task ----");
Console.WriteLine($"Ended task that uses global cancellation token only within itself. Should be no exceptions.");
Console.WriteLine($"{Environment.NewLine}{Environment.NewLine}Press enter to continue to next test...");