2

Where in Visual Studio 2012 nanosleep() gone? What include i need to add to get the nanosleep(), or what is the best way to make a delay in miliseconds in C++ Visual Studio 2012?

Timur Kukharskiy
  • 303
  • 3
  • 16

1 Answers1

3

You could try this, which is portable, Standard C++11 code:

#include <thread>
#include <chrono>

// ...

std::this_thread::sleep_for(std::chrono::milliseconds(1000));

Alternatively, you could use the Windows API Sleep() (declared in the WinBase.h Windows header):

::Sleep(1000);
Andy Prowl
  • 119,862
  • 22
  • 374
  • 446