April 2018
Intermediate to advanced
300 pages
7h 41m
English
The pipeline pattern is commonly used in scenarios where we need to execute the asynchronous tasks in sequence:

Consider a task where we need to create a user record first, then initiate a workflow and send an email. To implement this scenario, we can use the ContinueWith method of TPL. Here is a complete example:
static void Main(string[] args)
{
Task<int> t1 = Task.Factory.StartNew(() =>
{ return CreateUser(); });
var t2=t1.ContinueWith((antecedent) => { return InitiateWorkflow(antecedent.Result); });
var t3 = t2.ContinueWith((antecedant) => { return SendEmail(antecedant.Result); }); Console.Read(); } public static int ...