I've commented on Eric Lippert's answer to What's the difference between Task.Start/Wait and Async/Await?
I am asking this question since I am still unsure if I understand the concept correctly and how I'd achieve my goal. Adding tons of comments is not very helpful for anyone.
What I understand: await tells the compiler that the current thread has the capacity to perform some other computation and get back once the awaited operation is done. That means the workflow is interrupted until the awaited operation is done. This doesn't speed up the computation of the context which contains the await but increases the overall application performance due to better usage of workers.
No my issue: I'd like to continue the workflow and in the end make sure the operation is done. So basically allow the worker to continue the current workflow even if the awaitable operation is not complete and await completion at the end of the workflow. I'd like the worker to spend time on my workflow and not run away and help someone else.
What I think might work: Consider n async Add
operations and a Flush
operation which processes added items. Flush
requires the items to be added. But adding items doesn't require the previous item to be added. So basically I'd like to collect all running Add
operations and await all of them once all have been added. And after they have been awaited they should be Flush
ed.
- Can I do this by adding the
Add
Tasks to a list and in the end await all those tasks? - Or is this pseudo-async and has no benefit in the end?
- Is it the same as awaiting all the
Add
operations directly? (Without collecting them)