473,320 Members | 2,146 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Problem using sleep

39
Hi
I am using the sleep function to pause for few minutes, but this sleep function always start first no matter wheree in the program its used. like
....

function1();
sleep(10);
function2();

sleep is executing first .

How this can be solved, I tried to use fflush() before sleep but didn' t worked
Apr 30 '07 #1
10 3336
Savage
1,764 Expert 1GB
Hi
I am using the sleep function to pause for few minutes, but this sleep function always start first no matter wheree in the program its used. like
....

function1();
sleep(10);
function2();

sleep is executing first .

How this can be solved, I tried to use fflush() before sleep but didn' t worked
Are those functions returning a value?If they do u can do it like:

function1()-on succes returns 1 else returns 0
if(function1()) call sleep();

Savage
Apr 30 '07 #2
atlkhan
39
No funtions are not returning any value. But why the sleep() function do not follow the sequential flow of the program?
May 1 '07 #3
ilikepython
844 Expert 512MB
No funtions are not returning any value. But why the sleep() function do not follow the sequential flow of the program?
Are you sure? Make sure you have some cout or printf statements in the functions to know if they run or not.
May 1 '07 #4
atlkhan
39
Yes I am sure, sleep function just runs first and than the other functions. Any clue why the sequential flow is broken in sleeps case?
May 1 '07 #5
Savage
1,764 Expert 1GB
No funtions are not returning any value. But why the sleep() function do not follow the sequential flow of the program?
Would it be a problem to make the functions return values?


Savage
May 1 '07 #6
JosAH
11,448 Expert 8TB
Yes I am sure, sleep function just runs first and than the other functions. Any clue why the sequential flow is broken in sleeps case?
Have you put a print statement following the first function call and flushed the
output stream? function1() is called first, then sleep() and then function2().
Not flushing the output stream may obfuscate matters.

kind regards,

Jos
May 1 '07 #7
AdrianH
1,251 Expert 1GB
Sleep is not a standard function. How is it defined?


Adrian
May 1 '07 #8
Savage
1,764 Expert 1GB
Sleep is not a standard function. How is it defined?


Adrian
Actually,sleep is function from DOS.h library in Turbo/Borland c/c++ or unistd.h in Unix g++.It has following decalration:

void sleep(unsigend secounds); for windows and

void sleep(unsigned milisecunds); for unix

Savage
May 1 '07 #9
AdrianH
1,251 Expert 1GB
Actually,sleep is function from DOS.h library in Turbo/Borland c/c++ or unistd.h in Unix g++.It has following decalration:

void sleep(unsigend secounds); for windows and

void sleep(unsigned milisecunds); for unix

Savage
As I said, it is not standard.

Since atlkhan didn't state any information as to what platform, what compiler, and what library he/she is using, for all we know, it could be a user defined function which is not implemented correctly.

atlkhan, can you give us some more information? Have you tried stepping through the code with a debugger? What is making you think that it is being executed first?


Adrian
May 1 '07 #10
Savage
1,764 Expert 1GB
As I said, it is not standard.

Since atlkhan didn't state any information as to what platform, what compiler, and what library he/she is using, for all we know, it could be a user defined function which is not implemented correctly.

atlkhan, can you give us some more information? Have you tried stepping through the code with a debugger? What is making you think that it is being executed first?


Adrian
I don't think that it is user defined function,but I agree with u:

We need more info.

Savage
May 1 '07 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: John Lull | last post by:
I'm writing a multithreaded COM server to manage a pool of hardware resources. All objects are designed to be thread-safe, and I've set sys.coinit_flags to COINIT_MULTITHREADED before importing...
3
by: Canes_Rock | last post by:
The information posted at: ...
0
by: David | last post by:
I've written a small windows service, and I'm having a problem that I'm spending a lot more time on than I'd like. If anyone has experienced this problem and has any hints or solutions; they would...
5
by: Leonardo Hyppolito | last post by:
Hello! I am trying to implement a program that uses Threads. I chose the producers and consumers scenario. The producers put a "product" (which is an int number) in a shared storage place of one...
11
by: zaebos | last post by:
hi, i have this code which is part of a main program, to email from within the program a log file: int MailIt (char *mailserver, char *emailto, char *emailfrom, char *emailsubject, char...
5
by: Mikko Nylén | last post by:
Hi!, I'm trying to read the output of an process as it gets executed and append the output to a RichTextBox. However, I have a little problem: the process I'm trying to execute is a Python...
0
by: FlightController | last post by:
Hello Everyone, Not only am I new to the forum I am entirely new to programming in VBA. I am having a problem getting some sample code working. To give you background on what I want it to do: I...
5
by: CCLeasing | last post by:
For an application I'm creating I want to create a 'fake' progress bar. By fake I mean a progress bar that looks like it's doing something but actually isn't. I know philosophically this isn't...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.