Nested task-then and return value

Jul 8, 2015 at 5:54 PM
I'm quite new to pplx stuff, got a question. how do I return a value from topmost task when I set the value in the bottommost task?

something like
task<result> foobarbaz()
{
foo.dosomething().then([](task<bar> a){
a.dosomethingelse().then([](taks<baz> b){
auto result = b.getsomedata();
});
}
);
}
how do I set the "result" data to the return value of "foobarbaz" function?
Coordinator
Jul 8, 2015 at 7:59 PM
Hi kreuzerkrieg,

Basically you can just return the change of task continuations you've made and everything will work. Try something like this:
task<result> foobarbaz()
{
    return foo.dosomething().then([](task<bar> a)
    {
        return a.dosomethingelse();
    }).then([](task<baz> b)
    {
        return b.getsomedata();
    });
}
For more resources on using PPL tasks, take a look here.

Steve
Jul 9, 2015 at 4:57 AM
Thanks Steve!