Sleep function

Namespace: Windows  |  Header: Windows.h

Syntax

VOID WINAPI Sleep(
    DWORD dwMilliseconds
);

Parameters

dwMillisecondsThe amount of time, in milliseconds, that the current thread is to be suspended. A value of zero yields the thread’s remaining quantum.

Return value

This function does not return a value.

Remarks

Note: On Windows 8 and later, the system may round the interval up to the nearest multiple of the system timer resolution.

Example

#include <windows.h>
#include <stdio.h>

int main(void)
{
    printf("Waiting for 2 seconds...\\n");
    Sleep(2000); // 2000 milliseconds = 2 seconds
    printf("Done!\\n");
    return 0;
}

See also