I need to schedule two tasks based on a condition as given below:
bool check();
task<int> Function_1();
task<int> Function_2();
Main()
{
if(check)
{
Function_1()
.then([](){
//Do some work here
return Function_2();
})
.then([](task<int> status){
//Do some work here
});
}
else
{
Function_2()
.then([](task<int> status)
{
// Do some work here
});
}
}
What is the best way to write such code without any redundancy? Is there a way to attach a continuation with a task that executes based on a condition.?
I know that this can be possible if the first task is cancelled, but we dont need to cancel that task.
Thanks in advance for your help.
Regards,
Parul Gupta
Parul Gupta