By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,699 Members | 1,209 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,699 IT Pros & Developers. It's quick & easy.

Imposing a delay in code execution

P: n/a
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
Nov 21 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Use the Thread.Sleep method.

"Marty" <xm******@hotmail.com> wrote in message
news:FSg3e.107325$KI2.52988@clgrps12...
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

Nov 21 '05 #2

P: n/a
"Marty" <xm******@hotmail.com> schrieb:
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.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #3

P: n/a
Great,
that's really nice :)
Marty

Marina wrote:
Use the Thread.Sleep method.

"Marty" <xm******@hotmail.com> wrote in message
news:FSg3e.107325$KI2.52988@clgrps12...
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


Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.