I am using VS2013.
I just read this and found that a future should block in its destructor.
I tried some code but the std::future
did not block.
void PrintFoo()
{
while (true)
{
std::cout << "Foo" << std::endl;
Sleep(1000);
}
}
int _tmain(int argc, _TCHAR* argv[])
{
{
auto f = std::async(std::launch::async, PrintFoo);
}
while (true)
{
Sleep(1000);
std::cout << "Waiting" << std::endl;
}
std::cout << "Before application end" << std::endl;
return 0;
}
I have the output:
Foo
Waiting
Foo
Waiting
Am I misunderstanding something?