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?
Printable View
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?
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);
...
yes but that pauses the entire prog. I just want to pause it in a function. isn't there any other way???
>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.
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.
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.............................................. ..
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.