473,491 Members | 2,205 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Imposing a delay in code execution

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
3 2549
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
"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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
5864
by: Jason Shohet | last post by:
Lets say I want a button to execute 10 seconds after I press it, not immediately. Any ideas how to cause that, in a code-behind. IMO its only server side code, I don't think javascript needs to...
18
3227
by: Max | last post by:
This is a follow-up on my previous thread concerning having the program wait for a certain date and time and then executing some code when it gets there. My question is; can I use the Sleep...
4
782
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I make a 10 second delay? ----------------------------------------------------------------------- There...
1
3619
by: klmishraa79 | last post by:
i want to know how i can put a time delay between two command execution...i.e. after first command of programm the second command should execute after some fixed delay......i want to use time delay...
1
6990
by: maul581 | last post by:
I know the delay( ) function of Turbo C and used it in my project. By this function we can give intermediate delay in execution from 1 millisecond to 9999 millisecond. My main question is "Is it...
0
7115
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7154
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6858
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5451
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4881
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3076
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1392
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
633
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
280
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.