create_task with asynchronous unwrapping PPL
-
I have a code as below.
// async-unwrapping.cpp
// compile with: /EHsc
#include
#includeusing namespace concurrency;
using namespace std;int wmain()
{
auto t = create_task([]()
{
wcout << L"Task A" << endl;// Create an inner task that runs before any continuation // of the outer task. return create\_task(\[\]() { wcout << L"Task B" << endl; }); }); // Run and wait for a continuation of the outer task. t.then(\[\](task& t3) // or task t3 { wcout << L"Task C" << endl; t3.wait(); // or .get() }).wait();
}
I expected the output to be /* Output: Task A Task B Task C Task B */ But the output is /* Output: Task A Task B Task C */ Why t3.wait(); isn't calling the B task again or a tleast should throw error?
Jesus saves
-
I have a code as below.
// async-unwrapping.cpp
// compile with: /EHsc
#include
#includeusing namespace concurrency;
using namespace std;int wmain()
{
auto t = create_task([]()
{
wcout << L"Task A" << endl;// Create an inner task that runs before any continuation // of the outer task. return create\_task(\[\]() { wcout << L"Task B" << endl; }); }); // Run and wait for a continuation of the outer task. t.then(\[\](task& t3) // or task t3 { wcout << L"Task C" << endl; t3.wait(); // or .get() }).wait();
}
I expected the output to be /* Output: Task A Task B Task C Task B */ But the output is /* Output: Task A Task B Task C */ Why t3.wait(); isn't calling the B task again or a tleast should throw error?
Jesus saves