Results 1 to 3 of 3

Thread: Do I have a correct understanding of TaskContinuationOptions below?

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2003
    Posts
    782

    Do I have a correct understanding of TaskContinuationOptions below?

    Hi All,

    Do I have a correct understanding of TaskContinuationOptions below?

    Scenario:

    1. Processing_OrdersAsync -> is to process an order, and if it returns true (to t2)
    2. Checking_PaymentAsync -> is to process the payment of the order, and if it returns true (to t3)
    3. Prepare_DeliveryAsync -> is to process the delivery of the order, and if it returns true, it will do Send_Email_Delivery_NotificationAsync

    I'm curious about TaskContinuationOptions.OnlyOnRanToCompletion, what's correct TaskContinuationOptions for the main process? and do I have correct TaskContinuationOptions.AttachedToParent?

    Code:
                 await Sales.Processing_OrdersAsync(_ja_order_details).ContinueWith(async (t1) =>
                {
                    JObject _jo_processing_orders = (JObject)t1.Result;
    
                    if ((bool)_jo_processing_orders["result"])  
                    {
                        await Sales.Checking_PaymentAsync(_jo_processing_orders).ContinueWith(async (t2) =>
                        {
                            if ((bool)t2.Result)
                            {
                                await Sales.Prepare_DeliveryAsync(_jo_processing_orders).ContinueWith(async (t3) =>
                                {
                                    if ((bool)t3.Result)
                                    {
                                        await Sales.Send_Email_Delivery_NotificationAsync(_jo_processing_orders["customer"]["email"]);
                                    }
    
                                }, TaskContinuationOptions.AttachedToParent);
                            }
    
                        }, TaskContinuationOptions.AttachedToParent);
                    }
                }, TaskContinuationOptions.OnlyOnRanToCompletion);
    Last edited by Winanjaya; Jun 30th, 2021 at 09:51 PM.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,296

    Re: Do I have a correct understanding of TaskContinuationOptions below?

    Is there a specific reason that you want to attach those child tasks to their parent?

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2003
    Posts
    782

    Re: Do I have a correct understanding of TaskContinuationOptions below?

    yes, because I have to make sure that the previous task is returning true before continuing to next process

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width