Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 12111

Can I setup an async operation to happen automatically after another async operation has completed?

$
0
0

I have a bit of a weird case. I have a list that looks something like:

var myStuff = [A:1, A:2, A:3, B:1, B:2, C:1, C:2, C:3, C:4];

For all letters, I want to start Tasks for each version except for the last version. I want to run the last version when the previous versions have finished. To explain better:

  • Run a task for A:1
  • Run a task for A:2
  • When both those tasks finish, run a task for A:3

Repeat for B and C, ideally having A:1, B:1, C:1, A:2, B:2 etc, all running at the same time.

I figure I can use a Linq Groupby to get the list into 3 groups, sort by version and then start tasks for all but the last. I'm not sure how to do this in a way where I can both have the last version (A:3, B:2, C:4) wait for the previous tasks while ALSO making sure A:1, B:1, C:1, A:2, B:2, C:2 etc all run at the same time.

Is this possible?


Viewing all articles
Browse latest Browse all 12111

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>