Dependent Asynchronous operation example:
In below example we have 3 tasks t1,t2 and t3. Task t1's result will be used in t2 and t2's result will be used in t3.
Operation t1 will take more time to complete as I have used Thread.Sleep(10000) so it will take 10 second to complete it's operation.
class DependentAwait
{
public static void Main()
{
Task
Console.WriteLine("Final Result=" + t.Result);
Console.ReadKey();
}
public async static Task
{
Task
await t1;
Task
await t2;
Task
return await t3;
}
public static int M1(int a,int b)
{
return a + b;
}
}
Output : Result of above program would be 19.
No comments:
Post a Comment