Click here to Skip to main content
13,300,331 members (50,676 online)
Rate this:
Please Sign up or sign in to vote.
See more:
I have multiple tasks in my project, and I want a method executed when all the tasks done, how to do that? like Task.WhenAll, but I don't know how to use it.
Posted 25-Nov-12 16:19pm
Updated 26-Nov-12 16:28pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

This is covered in the documentation, but here is a simple example...

Task[] tasks = new Task[3]
    Task.Factory.StartNew(() => MethodA()),
    Task.Factory.StartNew(() => MethodB()),
    Task.Factory.StartNew(() => MethodC())
//Block until all tasks complete.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.171207.1 | Last Updated 7 Dec 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100