using System.Threading.Tasks;
public static async Task Main()
var cancellationToken = new CancellationTokenSource(TimeSpan.FromSeconds(3));
await Program.RunWorkerAsync(cancellationToken.Token);
Console.WriteLine("EndedTask");
public static async Task RunWorkerAsync(CancellationToken cancellationToken) {
await Task.Delay(TimeSpan.FromSeconds(1), cancellationToken);