home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!decwrl!pa.dec.com!nntpd2.cxo.dec.com!nntpd.lkg.dec.com!ryn.mro4.dec.com!rdg.dec.com!decvax.dec.com!enigami.mv.com!enigami.mv.com!cory
- From: cory@enigami.mv.com (Cory Kempf)
- Newsgroups: comp.sys.mac.programmer
- Subject: Re: How do I sleep w/o using any CPU time
- Date: Fri, 24 Jul 92 11:52:07 EST
- Organization: EnigamI, Inc., Nashua, NH
- Message-ID: <0105011F.9b7r6a@dragon.enigami.mv.com>
- Reply-To: cory@enigami.mv.com
- X-Mailer: uAccess - Macintosh Release: 1.5v5
- Lines: 63
-
-
- In article <dowdy-200792081218@90.10.20.25> (comp.sys.mac.programmer), dowdy@apple.com (Tom Dowdy) writes:
- >In article <1992Jul13.150027.4926@usenet.ins.cwru.edu>, yjc@po.cwru.edu
- >(Jerome Chan) wrote:
- >>
- >> In article <0105011F.8acslo@dragon.enigami.mv.com> Cory Kempf,
- >> cory@enigami.mv.com writes:
- >> >The way to give up the CPU is to call WaitNextEvent, passing it a
- >> >large number of the 3rd parameter (time that WNE can give away).
- >> >I usually use 50 or so (there was this bug a while back...). By putting
- >> >this inside a while loop that checks the tickcount, I give away as
- >> >much CPU as I can.
- >>
- >> Hmm. But won't we be losing events if we do this? If windows are being
- >> displayed and the user switches to another application under
- >> multi-finder, won't we lose the the Update Event? Or is that the
- >> Resume/Suspend Event?
- >
- >Actually, you won't be losing events - however, there is a potential
- >serious
- >problem with calling WNE this way all of the time. Note that in *this*
- >particular case, the original poster (long since gone from this discussion,
- >I would fear) wasn't going to have any windows open - he was simply running
- >until an event happened, at which time a dialog box would be brought
- >up.
-
- No, I'm still here, just a bit behind.
-
- And yes, when I do actually do a delay like that, I am usually initializing
- my application, which (in many cases) requires that I wait for some
- hardware to respond. The only window open at this point is the splash
- screen. Normally though there is the possibility that the user would wish
- to interact with them or make a selection from a menu (like Quit!), so I
- would call my Yield(long time) routine instead. Yield() repeatedly calls
- my main event function (the looping is done externaly) until 'time' had
- passed. This has the added benefit of making sure the mouse was correct.
-
- Some other magic was in place to prevent re-entrancy.
-
- Usually though, if I am doing something that is long and involved,
- I would put up a dialog box with a thermometer in it (movable modal,
- of course!) to let the user know how much longer until I was finished.
-
- >However, if you *do* have windows open, and fail to respond to update
- >events, you will see very sluggish performance on your Mac as the
- >process manager attempts to give you updateEvents over and over again.
- >Eventually, when it sees some very large number of update events go
- >by for the same window, it will assume you are clueless and clear
- >the updateRgn itself - however, this takes almost a minute and a half.
-
- Would this still happen if the first parameter to WNE was 0, indicating
- that I didn't want ANY events?
-
- +C
-
-
- -------------------------------------------------------------
- Cory Kempf EnigamI, Inc.
- cory@enigami.mv.com ...!decvax!enigami!cory
- Annon: wi.5036@wizvax.methuen.ma.us
-
- "F' cryin' out loud, it's *your* life; shouldn't you at least examine
- your lifestyle values to see if they are really what *you* want."
- --Keith Lim
-