Hacker News new | past | comments | ask | show | jobs | submit login

For dead-simple parallel execution of a handful of jobs, IMO nothing beats mapping data to tasks with Linq and then "await Task.WhenAll". And if they have to share data, use something in System.Collections.Concurrent.



For fun bits of API inconsistency there, would you think that...

"task.Wait()" is to "await task" as "Task.WaitAll(tasks)" is to "await Task.WhenAll(tasks)"?

Maybe it's just me, but I sure did.


WhenAll returns a task (a promise, essentially) that completes "when all" its arguments have completed.


I seem to have misremembered, the odd one out was WhenAny, and the issue is that it crashes when given the empty set, instead of waiting forever (which is fine if you're dealing with a specific number of tasks, but not fine if you're actually using it for a dynamic number of tasks).

I could have sworn it was WaitAll, but heck - clearly not! Sorry :-).




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: