Is there a proper way to cancel an asynchronous task?
问题 I encountered a problem how to properly cancel an asynchronous task. Here is some draft. My entry point runs two asynchronous task. The first task does some 'long' work and the second one cancels it. Entry point: private static void Main() { var ctc = new CancellationTokenSource(); var cancellable = ExecuteLongCancellableMethod(ctc.Token); var cancelationTask = Task.Run(() => { Thread.Sleep(2000); Console.WriteLine("[Before cancellation]"); ctc.Cancel(); }); try { Task.WaitAll(cancellable,