Hello,
I want to write a time delay function like "Timedelay(floa t time_lenth){}".
When execute it, it will delay some seconds as long as "time_lenth "
indicating. Could you help on how to write such a function?
----------------
lovely newsgroup
---------------- 24 16138
Chen Shusheng wrote:
Hello,
I want to write a time delay function like "Timedelay(floa t time_lenth){}".
When execute it, it will delay some seconds as long as "time_lenth "
indicating. Could you help on how to write such a function?
----------------
lovely newsgroup
----------------
usleep() is one way to do it ( whereas it is supported ).
Chen Shusheng said:
Hello,
I want to write a time delay function like "Timedelay(floa t
time_lenth){}".
When execute it, it will delay some seconds as long as "time_lenth "
indicating. Could you help on how to write such a function?
#include <time.h>
void Timedelay(float time_lenth)
{
time_t start = time(NULL);
time_t end;
do
{
end = time(NULL);
} while(difftime( end, start) < time_lenth);
}
(Presumably 'lenth' is meaningful somewhere in the world.)
--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999 http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Thanks.
"Richard Heathfield" <in*****@invali d.invalid>
??????:XY****** **************@ bt.com...
Chen Shusheng said:
>Hello, I want to write a time delay function like "Timedelay(floa t time_lenth){}". When execute it, it will delay some seconds as long as "time_lenth " indicating. Could you help on how to write such a function?
#include <time.h>
void Timedelay(float time_lenth)
{
time_t start = time(NULL);
time_t end;
do
{
end = time(NULL);
} while(difftime( end, start) < time_lenth);
}
(Presumably 'lenth' is meaningful somewhere in the world.)
--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999 http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Richard Heathfield <in*****@invali d.invalidwrites :
Chen Shusheng said:
> I want to write a time delay function like "Timedelay(floa t time_lenth){}". When execute it, it will delay some seconds as long as "time_lenth " indicating. Could you help on how to write such a function?
#include <time.h>
void Timedelay(float time_lenth)
{
time_t start = time(NULL);
time_t end;
do
{
end = time(NULL);
} while(difftime( end, start) < time_lenth);
}
(Presumably 'lenth' is meaningful somewhere in the world.)
That's a portable way to do it, but not a good way to do it. By
calling time() repeatedly in a loop, it's likely (on a
multi-processing system) to gobble lots of CPU time.
Most systems provide a way to do this kind of thing, though standard C
doesn't.
--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
"Chen Shusheng" <cs*****@gmail. comwrote:
I want to write a time delay function like "Timedelay(floa t time_lenth){}".
When execute it, it will delay some seconds as long as "time_lenth "
indicating. Could you help on how to write such a function?
You use a system-specific function, which you can ask for in a
system-specific newsgroup.
Alternatively, you _could_ use a busy-loop, and be killed by your
systems manager for tying up the system.
Richard
"Richard Bos" <rl*@hoekstra-uitgeverij.nlд ÈëÏûÏ¢ÐÂÎÅ:45** *************** @news.xs4all.nl ...
"Chen Shusheng" <cs*****@gmail. comwrote:
> I want to write a time delay function like "Timedelay(floa t time_lenth){}" . When execute it, it will delay some seconds as long as "time_lenth " indicating. Could you help on how to write such a function?
You use a system-specific function, which you can ask for in a
system-specific newsgroup.
Alternatively, you _could_ use a busy-loop, and be killed by your
systems manager for tying up the system.
Richard
My system is windowsXP. Where should I post to get the answer? Could you pls
indicate?
Keith Thompson said:
<snip>
That's a portable way to do it, but not a good way to do it.
He didn't ask for a good way to do it. By posting in comp.lang.c, he asked
for a comp.lang.c way to do it.
--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999 http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Chen Shusheng wrote:
"Richard Bos" <rl*@hoekstra-uitgeverij.nlд ÈëÏûÏ¢ÐÂÎÅ:45** *************** @news.xs4all.nl ...
>"Chen Shusheng" <cs*****@gmail. comwrote:
>> I want to write a time delay function like "Timedelay(floa t time_lenth){} ". When execute it, it will delay some seconds as long as "time_lenth " indicating. Could you help on how to write such a function?
You use a system-specific function, which you can ask for in a system-specific newsgroup. Alternativel y, you _could_ use a busy-loop, and be killed by your systems manager for tying up the system.
Richard
My system is windowsXP. Where should I post to get the answer? Could you pls
indicate?
Start at http://msdn.microsoft.com/ . If you need a newsgroup - query
your news server for windows programming groups.
"Nils O. Selåsdal" wrote:
Chen Shusheng wrote:
>"Richard Bos" <rl*@hoekstra-uitgeverij.nl> дÈëÏûÏ¢ÐÂÎÅ:4 5************** ***@news.xs4all .nl...
>>"Chen Shusheng" <cs*****@gmail. comwrote:
I want to write a time delay function like "Timedelay(floa t time_lenth){ }". When execute it, it will delay some seconds as long as "time_lent h" indicating . Could you help on how to write such a function? You use a system-specific function, which you can ask for in a system-specific newsgroup. Alternatively , you _could_ use a busy-loop, and be killed by your systems manager for tying up the system.
Richard
My system is windowsXP. Where should I post to get the answer? Could you pls indicate?
Start at http://msdn.microsoft.com/ . If you need a newsgroup -
query
your news server for windows programming groups.
The things to look for are SetTimer and KillTimer... These are
Windows-API and thus off topic here. Just to provide a reference for
future lookups. If you need higher resolution use the
multimedia-timer. It's also described there.
HTH
--
Johannes
You can have it:
Quick, Accurate, Inexpensive.
Pick two. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: gmv |
last post by:
Hi,
I am doing a project and i would like to know if anyone can please tell me how to write a delay or wait function in c++ which works asynchronously with other programs.
Thank you,
GMV
|
by: notregister |
last post by:
I'm to delay my program for some limited time...i try using the following
codes but it doesn't work, how do i do a time delay???
'Extracted from the main function
Timer11.Start()
Do
tCC = timeCount
Loop Until timeCount > 10000
|
by: jayasakthi |
last post by:
when we freeze the columns of a table in jsp, there is a time delay in scrolling the page.
when we unlock the columns the time delay is not there.
is there any solution for decreasing the time delay without locking the columns.
|
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 other than sleep or timer....is it there any direct delay command like it is in c and c+...looking for ur suggestions.....thanks
|
by: Martin Wells |
last post by:
I'm doing an embedded systems project and I'm programming it as fully-
portable C89 (except of course for setting the pin values).
I need to put delays in the program, in the vicinity of 250 ms. (They
don't need to be exact).
Does C have a built-in method of putting in delays?
If not, I was thinking of defining a macro called "FLOPS" (i.e.
floating-point operations per second) and then doing something like:
| |
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 possible to get delay less than 1 millisecond in Turbo C"? If by changin any header file (e.g. dos.h) or by creating my own "delay" function, at any way Can I get delay less than 1 millisecond?
If in C it is not possible than please suggest me any...
|
by: Ali Rizwan |
last post by:
Hello all,
I want to put delay in my loops as we use in c/c++..
Is there any delay function in vb6 which put delay between any code???
Thanx
>> ALI <<
|
by: Rahina |
last post by:
I am working in Dreamweaver 8, and I have created a simple form: http://www.realmofmystery.com/app.html
This is a free website I am doing for some friends, so nothing fancy. And, I learned web design before all the CGI and PHP stuff got big, so I prefer to do things simply.
The form worked fine, emails the results like perfect, but it refused to redirect the page to the confirmation. I thought I could add an onClick to the submit button,...
|
by: Craig Williamson |
last post by:
I'm trying to write a time delay loop in Borland C 3.1 (for legacy
code) which has an accuracy of about 0.1ms. This change is due to a
hardware change and the software is now running too fast to take
proper readings. I have been using delay(1) in the past but it does
not have the accuracy that I need for this situation. Does anyone
know of a useful C function which can be used to create the time
delay? If anyone could help that would...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |