I have an array of Task<T> objects and would like to block until all have returned. How would I do this? (This is in a debugging view so performance is not an issue).
Basically, what is the task library equivalent of jquery’s $.when?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you want to block, you can use
Task.WaitAll(yourTasks);. If you want to use a continuation that fires when they’re all done (and are either using .NET 4.5 or the AsyncTargetingPack for .NET 4.0), you can useTask.WhenAll(yourTasks).ContinueWith(t => ...);