Imposing a delay in code execution

  • Thread starter Thread starter Marty
  • Start date Start date
M

Marty

Hi,

Is there a "light" way on CPU usage to delay a process in the code
execution. For example, if I want a function to wait 5 seconds before
continue executing without using a timer.

Is there a better way than using this:
While (MyCondition is true)
System.Windows.Forms.Application.DoEvents()
End While

Thanks,
Marty
 
Marty said:
Is there a "light" way on CPU usage to delay a process in the code
execution. For example, if I want a function to wait 5 seconds before
continue executing without using a timer.

Is there a better way than using this:
While (MyCondition is true)
System.Windows.Forms.Application.DoEvents()
End While

'System.Threading.Thread.Sleep(<number of milliseconds>)' will block the
currently executing thread.
 
Back
Top