#include <ppltasks.h>
#include <string>
#include <windows.h>
using namespace concurrency;
using namespace std;
int wmain()
{
auto t = create_task([]()
{
DWORD ms;
wchar_t str[40];
for (int i = 0; i < 3; i++)
{
ms = GetTickCount(); // Win32 API()
swprintf(str, 40, L"A: Time %d ミリ秒\n", ms);
OutputDebugString(str);
Sleep(rand() % 100);
}
});
t.then([]()
{ OutputDebugString(L"Run Task\n");
}).wait();
}auto t = create_task(・・・) でタスクを生成。
t.then([]() でタスクが起動され、.wait(); で終了を待ち合せます。
L"Run Task\n" はタスクが終了したときに印字されます。