home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.mac.programmer
- Path: sparky!uunet!nih-csl.dcrt.nih.gov!FAXCSL!FIXER
- From: fixer@faxcsl.dcrt.nih.gov (Chris Spiral Catfish Tate)
- Subject: Re: best way to pause in app ?
- Message-ID: <1992Nov20.135348.1785@alw.nih.gov>
- Sender: postman@alw.nih.gov (AMDS Postmaster)
- Reply-To: fixer@faxcsl.dcrt.nih.gov
- Organization: Computer Systems Laboratory, DCRT, NIH
- References: <brownlow.722219238@stmartin>
- Date: Fri, 20 Nov 1992 13:53:48 GMT
- Lines: 42
-
- In article <brownlow.722219238@stmartin>, brownlow@informix.com (Keith Brownlow) writes:
- >Is there a toolbox command to make the application wait x number of seconds
- >before continuing processing ? I've tried looping for 1000's of seconds but
- >without doing anything in the loop, it's more or less instantly coming back.
-
- Several things you can use (code given in C):
-
- 1) You could use Delay(60L * num_of_seconds, &dummy_long);
-
- This is okay, except that it pretty much freezes the machine until the
- delay is over, i.e. no background processing.
-
- 2) You could call WaitNextEvent(0, &dummy_event, 60L * num_of_seconds, 0L);
-
- This would give time to other processes, but would not necessarily give
- them the full time you specify. If you're the only process running, for
- example, you would return immediately.
-
- 3) Combination approach:
-
- long timeNow;
-
- timeNow = TickCount();
- while (TickCount() - timeNow < 60L * num_of_seconds)
- {
- (void) WaitNextEvent(0, &dummyEvent, 0L, 0L);
- }
-
- This repeatedly gives time to other processes until the specified amount
- of time has elapsed, at which point you drop out of the while loop.
-
- Calling Delay() for long periods of time (i.e. seconds) is pretty anti-
- social to other processes; I'd probably use approach 3) if I were going to
- be pausing for more than about a second. The one caveat is that you *might*
- not get control back for a much longer time, if another process is trying to
- hog the machine by not calling WaitNextEvent().
-
- ------------------------------------------------------------------------------
- Christopher Tate | The Leadfoot Collection, Continued:
- Management System Designers | * Heavy Fuel (Dire Straits)
- | * Last Scene in September (Preston Reed)
- fixer@faxcsl.dcrt.nih.gov | Because driving fast is a cathartic experience.
-