delay

Suspends execution for an interval (milliseconds)

Local Servers:blocking
Remote Servers:N/A
Classification:3.x, 4.x, 5.x, 6.x
Service:Thread

Syntax

  #include <nwthread.h>  
   
  void delay  (  
     unsigned   milliseconds); 
  

Parameters

milliseconds
(IN) Specifies the number of milliseconds the calling thread is to be delayed.

Return Values

This function returns no value. If an error occurs, errno is set to:

Value

Name

Description

–1

ENOMEM

Not enough memory.

Remarks

The delay function puts the calling thread to sleep for the number of milliseconds specified by the milliseconds parameter, rounded up to the next system clock tick.

NOTE:In practical application, the thread is delayed until it regains control of the processor, which might be considerably longer than the specified number of milliseconds.

A thread blocked on delay can be restarted (that is, delay can be cancelled) by calling ResumeThread.

See Also

EnterCritSec, SuspendThread, ThreadSwitch

Example

  #include <nwthread.h>  
  #include <stdio.h>  
  #include <nwconio.h>  
   
  main()  
  {  
     printf("start");  
     delay(10000);  
     printf("end");  
     getch();  
  }