"Async Generators"

public async IAsyncEnumerable<DataBatch> GetDataPaginated([EnumeratorCancellation] CancellationToken cancellationToken = default) {
	var paginationToken = new PaginationToken();
	
	try {		
		var results = await _database.GetNextResultBatch(paginationToken, cancellationToken);
		if (!results.ContainsValues) yield break;
		else yield return results.Batch;
	}
	catch (TaskCancelledException) {
		yield break;
	}
}


Code snippet taken from "Two Decades of C#: A Reference - C# 8".