-
-
Save Ershad95/ed0f504b586075efadfcc1d69c262191 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[HttpGet] | |
public async IAsyncEnumerable<Customer> Get(CancellationToken cancellationToken) | |
{ | |
while (!cancellationToken.IsCancellationRequested && _customers.Any(_ => _.Key % 10 == 0)) | |
{ | |
var customer = _customers.First(_ => _.Key % 10 == 0); | |
yield return new Customer(customer.Value.Name, customer.Key); | |
_customers.Remove(customer); | |
await Task.Delay(500,cancellationToken); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment