让异步代码工作,但是看不到我如何在主代码中使用返回值。这可能吗?我见过的所有例子都显示了.then延续中的所有逻辑。我不想将所有代码转换为异步只是web api调用。
pplx::task<void> GetXMLAsync() {
http_client client("url")
return client.request().then([=](http_response response) {
<< get result, parse it and return the **values** >>
});
int main(int argc, char* argv[]){
GetXMLAsync().wait();
use the **values** in the rest of the code
}
欣赏对此的任何见解。感谢
答案 0 :(得分:0)
我明白了。
pptx::task<http_response> test() {}
auto request_task = test();
auto response = request_task.get();
然后您可以根据需要使用响应变量。希望这有助于其他人。