Cancel Inner Task in task_group.run

Jan 27, 2015 at 1:32 AM
Edited Jan 27, 2015 at 4:04 AM
** edit **

Nevermind, just realized this is PPL issue, not C++Rest. Mod can delete this post.
in .h:
task_group tasks;

in .cpp:
task<int> Foo()
{
     ...
}

in .cpp:
tasks.run([]
{
    auto t = Foo();
    auto r = t.get();
});
I can cancel all tasks in the group by calling tasks.cancel() and then tasks.wait(), but it won't cancel the inner task in the lambda. Is there any way to do that?
Coordinator
Jan 27, 2015 at 5:16 PM
Hi BrassSlide,

Yes you are correct this question is specific to PPL. A task and a task_group have no knowledge of each other so canceling the task_group won't can the task returned from the function Foo(). If you wanted to group them together you probably use a cancellation_token with both the task and the task_group, they you could cancel them all in one go.

Steve