static public async void Main() { // Create a cancellation token source to cancel // if the operation takes more than a minute. using (CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(1000 * 60)) { try { await foreach (string fileName in EncryptFilesAsync() .WithCancellation(cancellationTokenSource.Token)) { Console.WriteLine(fileName); } } finally { Cryptographer?.Dispose(); } } }