Thread: how do you....

  1. #1
    Registered User
    Join Date
    Jul 2004
    Posts
    14

    how do you....

    how do you make the prog to wait 1 sec? I wanna make it so it would do a function every 1 sec. is this possible?

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    It's possible, but not portable. How you would go about this depends on what system and compiler you use. But because most of the question askers around here use Windows, here's one way to do it:
    Code:
    #include <windows.h>
    
    ...
    Sleep(1000);
    ...
    My best code is written with the delete key.

  3. #3
    Registered User
    Join Date
    Jul 2004
    Posts
    14
    yes but that pauses the entire prog. I just want to pause it in a function. isn't there any other way???

  4. #4
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >I just want to pause it in a function.
    Unless you're using multiple processes or threads, the only thread of execution is the function that you're executing at the time. If you want two functions to perform simultaneously then you need to create another process or another thread, both of which are highly platform dependent at their simplest. So you'll want to move to a more appropriate forum.
    My best code is written with the delete key.

  5. #5
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    Unless you're using multiple threads of execution, they're the same thing. I assume you're not using multiple threads, so just use Sleep(1000)

    edit: While I'm on the subject - the 1000 is just the number of milliseconds you want to pause for, so that's how you would pause for other amounts of time.

  6. #6
    Registered User
    Join Date
    Jul 2004
    Posts
    14
    I know how to use Sleep. Only one thing, I'm using C++ Builder so I can create Windows Application with ease, so I want it so when 1 sec passes, it changes a part of the program with oausing the whole prog. Like when it's doing multiple things, when it's like 13% done, it updates the "percentdone" label I made.............................................. ..

  7. #7
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Have the progress bar be a seperate object, when your function that is unpacking everything detects that its now at a new percentage just make a call to another function that updates the progress bar.

Popular pages Recent additions subscribe to a feed