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);
AJM
  • 1,317
  • 2
  • 15
  • 30
Andy Prowl
  • 124,023
  • 23
  • 387
  • 451