473,473 Members | 1,951 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

sleep or delay

what should be used?
In a normal procedure (no thread) I would like to wait (do nothing) for few
secs.

I used a loop with with a clock , sleep and some thing else.

my concern is not to eat the cpu time. what shoul I use?

I see some thread.sleep, but will this work on a normal procedure?
shall I consider a procedure as a thread ? or are there any differences ?
Feb 13 '06 #1
4 1389
"raulavi" <ra*****@discussions.microsoft.com> schrieb
what should be used?
In a normal procedure (no thread) I would like to wait (do nothing)
for few
secs.

I used a loop with with a clock , sleep and some thing else.

my concern is not to eat the cpu time. what shoul I use?

I see some thread.sleep, but will this work on a normal procedure?
shall I consider a procedure as a thread ? or are there any
differences ?


A thread executes code. Your procedure belongs to that code. Use
Thread.Sleep to have the thread sleep.
Armin

Feb 13 '06 #2
> what should be used?
In a normal procedure (no thread) I would like to wait (do nothing) for few
secs.
my concern is not to eat the cpu time. what shoul I use?


Use System.Threading.Thread.Sleep(Milliseconds).

Feb 13 '06 #3
raulavi wrote:
what should be used?
In a normal procedure (no thread) I would like to wait (do nothing)
for few secs.

I see some thread.sleep, but will this work on a normal procedure?


Yes, and yes.

Andrew
Feb 13 '06 #4
CMM
If this helps to put it into perspective:

System.Threading.Thread.Sleep(...)
does the same thing AFAIK:
System.Threading.Thread.CurrentThread.Sleep(...)

--
-C. Moya
www.cmoya.com
"Andrew Morton" <ak*@in-press.co.uk.invalid> wrote in message
news:%2***************@TK2MSFTNGP09.phx.gbl...
raulavi wrote:
what should be used?
In a normal procedure (no thread) I would like to wait (do nothing)
for few secs.

I see some thread.sleep, but will this work on a normal procedure?


Yes, and yes.

Andrew

Feb 13 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Xaradas | last post by:
How can I suspend the execution of a script for x seconds? Does exists something like sleep(x)? Thanks. ------------------------------------ "Computer Science is no more about computers ...
7
by: John | last post by:
Thanks. I am writing a C++ code on Linux and Sun OS platform. How to make a procedure sleep or delay? Thanks again. "John Carson" <donaldquixote@datafast.net.au> wrote in message...
21
by: Alo Sarv | last post by:
Hi From what I have understood from various posts in this newsgroup, writing event loops pretty much comes down to this: while (true) { handleEvents(); sleep(1); // or _sleep() or...
1
by: Robert Huie | last post by:
Hi all, I'm trying to use asp.net to code a chat window and I would like to make the http request delay as long as possible till the process/thread detects a new incoming message. basically...
0
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...
2
by: andychambers2002 | last post by:
I've written a simple Timer class that allows you to extend it and then implement onMinuteChange, onHourChange etc methods which will be executed on each new minute/hour respectively. It works...
3
by: Steve Lowe | last post by:
Hi, I'm getting into VB.net with the help of a few books, but have got a problem grasping how to implement a system.timers.timer Only 1 of my 3 books mentions timers and that's a...
2
by: jrsjrs | last post by:
<?php echo "<BR><BR>A) Present time is:<BR>"; echo date('h:i:s') . "\n<BR>Delaying 5 seconds, new time is:<BR>"; sleep(5); echo date('h:i:s') . "\n<BR>"; ?> This first script delays 5...
13
by: Charles Zhang | last post by:
Sleep() function Sleep at lease 1 millisecond, there is a way to make a thread to sleep less than a millisecond? One way I know of is using performance counter which is not really sleep ( loop and...
2
by: virupax | last post by:
Which is the best one to use sleep or delay ( for a delay in the process ) .As i understand use of sleep, allows the kernel to schedule the process. And if a sleep of microseconds is used, and...
0
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
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
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
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
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...

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.