Reputation: 45947
i gote the following method and i want to pass the return values of the dosleep method:
static void Main(string[] args)
{
var t1 = Task.Factory.StartNew(() => dosleep(2000));
var t2 = Task.Factory.StartNew(() => dosleep(1000));
Task.WaitAll(t1,t2);
Console.WriteLine("All Done in {0} milliseconds!"); //t1+t2 here!!
}
public static int dosleep(int Milliseconds)
{
System.Threading.Thread.Sleep(Milliseconds);
Console.WriteLine("Task finished");
return Milliseconds;
}
Upvotes: 1
Views: 1986