-
Jun 30th, 2021, 09:33 PM
#1
Thread Starter
Fanatic Member
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.
-
Jun 30th, 2021, 09:40 PM
#2
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?
-
Jun 30th, 2021, 09:46 PM
#3
Thread Starter
Fanatic Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|