先看一个例子

#include <ppltasks.h>
#include <iostream>
using namespace Concurrency;
using namespace std;
int main()
{
    task<int> t([]() {
        return 10;
    });

    t.wait();
    wcout << t.get() << endl;
     return 0;
}

  

输出 10
 
       先解释下这段程序做了什么,task<int>定义了一个并行任务并设定会返回int型值,t的初始化用到了Lambda表达式,其中就涉及到一个异步处理(return 10),wait()会等待异步处理结束,从get()方法能得到异步处理的返回值。
 
http://blog.csdn.net/my_business/article/details/7490511
 

相关文章:

  • 2021-07-06
  • 2021-06-06
  • 2022-01-21
  • 2021-06-15
  • 2022-12-23
  • 2021-12-08
猜你喜欢
  • 2022-02-09
  • 2021-10-28
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-18
  • 2021-10-22
相关资源
相似解决方案