# Optimal way to iterate between await operator calls

Is there any cleaner way to implement the following?

await Task.Delay(100);
ExecutionProgress = .1;
ExecutionProgress = .2;
ExecutionProgress = .3;
ExecutionProgress = .4;
ExecutionProgress = .5;
ExecutionProgress = .6;
ExecutionProgress = .7;
ExecutionProgress = .8;
ExecutionProgress = .9;
ExecutionProgress = 1;


For example, something like this?

await Task.Iterate(100, () => { ExecutionProgress += .1; }, 10);

• await Task.Delay(100).ContinueWith(x=>ExecutionProgress += .1;);? You can extract progress update logic to separate function – Dmitry Pavliv May 21 '18 at 7:48
• This question is incomplete. To help reviewers give you better answers, please add sufficient context to your question. The more you tell us about what your code does and what the purpose of doing that is, the easier it will be for reviewers to help you. Questions should include a description of what the code does – Dannnno May 21 '18 at 17:58
• As has been discussed in chat, this is real code that is supposed to simulate a progressbar. – Simon Forsberg May 22 '18 at 12:56

decimal  progress = 0;

• I would prefer progress += 0.1 instead of doing division all the time. – Simon Forsberg May 22 '18 at 13:01
• It can be one-lined, but IMO it's uglier and less readable than the equivalent for loop that you've used. But I do like the cleverness of it: Enumerable.Range(0, 10).ToList().ForEach(fe => await Task.Delay(100).ContinueWith(x => progress += 0.1;);) Also, I think you forgot to account for int division. – Flater May 25 '18 at 12:35