Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- dispatcher = event_dispatcher::current_dispatcher();
- dispatcher->begin_invoke([]
- {
- cout << "begin invoke thread id... " << std::this_thread::get_id() << endl;
- }).then([]
- {
- cout << "then invoke thread id... " << std::this_thread::get_id() << endl;
- return 5;
- }, pplx::task_continuation_context::use_current()).then([](int c)
- {
- cout << "and then invoke thread id... " << c << std::this_thread::get_id() << endl;
- }, pplx::task_continuation_context::use_arbitrary());
- //Start first dispatcher on a new thread
- std::thread t([]
- {
- dispatcher->run();
- });
- t.detach();
- auto dispatcher2 = event_dispatcher::current_dispatcher();
- dispatcher2->begin_invoke([]
- {
- cout << "Running from second dispatcher" << endl;
- dispatcher->begin_invoke([]
- {
- cout << "running from first dispatcher" << endl;
- });
- });
- /* This blocks, current thread runs the loop */
- dispatcher2->run();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement