Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting a program to pause for a number of seconds

Status
Not open for further replies.

milage

Programmer
Jul 13, 2001
58
US
Hi,

I know there may have been similar questions in this forum but they didn't quite cover what I am getting at.

Basically I want my program to wait 10 seconds, increase a status bar by 1, wait another 10 seconds and increase a status bar by 1 and loop through this process.

(It will naturally do more than this but I will be able to cope once I have the basics, I hope)

I am not sure quite how to do this. I assume I have to use the timer class? The problem is that the SDK documentation seems to only refer to waiting for processes to finishing executing before continuing.

Any help would be much appreciated

cheers

Rob

 
Generally, status bars are used to update the user about the completion of a 'unit of work'. Doing 'busy waiting' as you are suggesting is counterintuitive. You just want the program to churn and update a status bar rather than doing any actual work?

In any event, here's a way...

while (statusBar.notCompleted()) {
try {
Thread.currentThread().sleep(10000);
} catch (InterruptedException e) {}
statusBar.increment(1);
}

BTW, I just made up the statusbar calls. You'll have to use whatever is appropriate for the class you are using.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top