Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <ppl.h>
- #include <ppltasks.h>
- int main(int argc, char* argv[])
- {
- using namespace std;
- concurrency::task<void> task;
- auto task_ticket = concurrency::create_task([]()
- {
- // A continuation task executed asynchronously
- // after the previous task has completed. This
- // is executed even if the previous task fails
- // by being cancelled or throwing an exception.
- throw std::runtime_error("Hello");
- })
- .then([]()
- {
- // This should be executed even though the
- // previous task failed.
- cout << "Task (2) executed" << endl;
- });
- try
- {
- task_ticket.wait();
- }
- catch (std::exception const& e)
- {
- cout << "Exception caughtn";
- }
- return EXIT_SUCCESS;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement