Wait - how ?

  • Thread starter Thread starter peteZ
  • Start date Start date
P

peteZ

How can I tell my C# program to do nothing for 5 secs ?

ie. I want to slow down a process and introduce a deliberate delay.



- peteZ
 
peteZ said:
How can I tell my C# program to do nothing for 5 secs ?

ie. I want to slow down a process and introduce a deliberate delay.

Hi Petz,

Try this:

using System.Threading;

....

Thread.Sleep(5000);


Joe
 
Won't that lock the app solid for 5 seconds? Better to use a loop with a DoEvents in it that checks for Now + 5seconds, or use a
timer.
 
Michael Culley said:
Won't that lock the app solid for 5 seconds? Better to use a loop with a
DoEvents in it that checks for Now + 5seconds, or use a

Sure, if he does it on the UI thread. The question wasn't that specific.
For long running processes, I'll consider pushing it off on a secondary
Thread or do an asynchronous call.

Joe
 
Back
Top