{"action":"opened","issue":{"url":"https://api.github.com/repos/Reactive-Extensions/RxCpp/issues/151","labels_url":"https://api.github.com/repos/Reactive-Extensions/RxCpp/issues/151/labels{/name}","comments_url":"https://api.github.com/repos/Reactive-Extensions/RxCpp/issues/151/comments","events_url":"https://api.github.com/repos/Reactive-Extensions/RxCpp/issues/151/events","html_url":"https://github.com/Reactive-Extensions/RxCpp/issues/151","id":89486489,"number":151,"title":"Observing on main thread","user":{"login":"hasyimibhar","id":1431045,"avatar_url":"https://avatars.githubusercontent.com/u/1431045?v=3","gravatar_id":"","url":"https://api.github.com/users/hasyimibhar","html_url":"https://github.com/hasyimibhar","followers_url":"https://api.github.com/users/hasyimibhar/followers","following_url":"https://api.github.com/users/hasyimibhar/following{/other_user}","gists_url":"https://api.github.com/users/hasyimibhar/gists{/gist_id}","starred_url":"https://api.github.com/users/hasyimibhar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hasyimibhar/subscriptions","organizations_url":"https://api.github.com/users/hasyimibhar/orgs","repos_url":"https://api.github.com/users/hasyimibhar/repos","events_url":"https://api.github.com/users/hasyimibhar/events{/privacy}","received_events_url":"https://api.github.com/users/hasyimibhar/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-06-19T07:00:02Z","updated_at":"2015-06-19T07:00:02Z","closed_at":null,"body":"In RxAndroid, there's `.observeOn(AndroidSchedulers.mainThread())`. How do you achieve that in RxCpp?\r\n\r\nFor example, how do I ensure that the call to `printf` below is executed on the main thread?\r\n```cpp\r\nauto numbers = rxcpp::observable<>::range(1, 100).subscribe_on(rxcpp::observe_on_new_thread());\r\nnumbers\r\n    .map([](int n) { return n * 2; })\r\n    .map([](int n) { return n + 1; })\r\n    .as_blocking()\r\n    .subscribe([](int n)\r\n    {\r\n        printf(\"Number: %d\\n\", n);\r\n    });"}}