Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Metro WinRT
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 15:19pm
Edited 26-Nov-12 15:28pm
v2

1 solution

Rate this: bad
good
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.
Task.WaitAll(tasks);
  Permalink  

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



Advertise | Privacy | Mobile
Web03 | 2.8.141022.2 | Last Updated 7 Dec 2012
Copyright © CodeProject, 1999-2014
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