Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. #include <ppl.h>
  4. #include <ppltasks.h>
  5.  
  6. int main(int argc, char* argv[])
  7. {
  8. using namespace std;
  9.  
  10. concurrency::task<void> task;
  11. auto task_ticket = concurrency::create_task([]()
  12. {
  13. // A continuation task executed asynchronously
  14. // after the previous task has completed. This
  15. // is executed even if the previous task fails
  16. // by being cancelled or throwing an exception.
  17. throw std::runtime_error("Hello");
  18. })
  19.  
  20. .then([]()
  21. {
  22. // This should be executed even though the
  23. // previous task failed.
  24. cout << "Task (2) executed" << endl;
  25. });
  26.  
  27. try
  28. {
  29. task_ticket.wait();
  30. }
  31. catch (std::exception const& e)
  32. {
  33. cout << "Exception caughtn";
  34. }
  35. return EXIT_SUCCESS;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement