home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / sys / mac / programm / 13023 < prev    next >
Encoding:
Internet Message Format  |  1992-07-25  |  3.4 KB

  1. 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
  2. From: cory@enigami.mv.com (Cory Kempf)
  3. Newsgroups: comp.sys.mac.programmer
  4. Subject: Re: How do I sleep w/o using any CPU time
  5. Date: Fri, 24 Jul 92 11:52:07 EST
  6. Organization: EnigamI, Inc., Nashua, NH
  7. Message-ID: <0105011F.9b7r6a@dragon.enigami.mv.com>
  8. Reply-To: cory@enigami.mv.com
  9. X-Mailer: uAccess - Macintosh Release: 1.5v5
  10. Lines: 63
  11.  
  12.  
  13. In article <dowdy-200792081218@90.10.20.25> (comp.sys.mac.programmer), dowdy@apple.com (Tom Dowdy) writes:
  14. >In article <1992Jul13.150027.4926@usenet.ins.cwru.edu>, yjc@po.cwru.edu
  15. >(Jerome Chan) wrote:
  16. >> 
  17. >> In article <0105011F.8acslo@dragon.enigami.mv.com> Cory Kempf,
  18. >> cory@enigami.mv.com writes:
  19. >> >The way to give up the CPU is to call WaitNextEvent, passing it a
  20. >> >large number of the 3rd parameter (time that WNE can give away). 
  21. >> >I usually use 50 or so (there was this bug a while back...).  By putting
  22. >> >this inside a while loop that checks the tickcount, I give away as
  23. >> >much CPU as I can.  
  24. >> 
  25. >>   Hmm. But won't we be losing events if we do this? If windows are being
  26. >> displayed and the user switches to another application under
  27. >> multi-finder, won't we lose the the Update Event? Or is that the
  28. >> Resume/Suspend Event?
  29. >
  30. >Actually, you won't be losing events - however, there is a potential
  31. >serious
  32. >problem with calling WNE this way all of the time.  Note that in *this*
  33. >particular case, the original poster (long since gone from this discussion,
  34. >I would fear) wasn't going to have any windows open - he was simply running
  35. >until an event happened, at which time a dialog box would be brought
  36. >up.
  37.  
  38. No, I'm still here, just a bit behind.
  39.  
  40. And yes, when I do actually do a delay like that, I am usually initializing
  41. my application, which (in many cases) requires that I wait for some
  42. hardware to respond.  The only window open at this point is the splash
  43. screen.  Normally though there is the possibility that the user would wish 
  44. to interact with them or make a selection from a menu (like Quit!), so I 
  45. would call my Yield(long time) routine instead. Yield() repeatedly calls 
  46. my main event function (the looping is done externaly) until 'time' had 
  47. passed. This has the added benefit of making sure the mouse was correct.
  48.  
  49. Some other magic was in place to prevent re-entrancy.
  50.  
  51. Usually though, if I am doing something that is long and involved,
  52. I would put up a dialog box with a thermometer in it (movable modal,
  53. of course!) to let the user know how much longer until I was finished.
  54.  
  55. >However, if you *do* have windows open, and fail to respond to update
  56. >events, you will see very sluggish performance on your Mac as the
  57. >process manager attempts to give you updateEvents over and over again.
  58. >Eventually, when it sees some very large number of update events go
  59. >by for the same window, it will assume you are clueless and clear
  60. >the updateRgn itself - however, this takes almost a minute and a half.
  61.  
  62. Would this still happen if the first parameter to WNE was 0, indicating
  63. that I didn't want ANY events?
  64.  
  65. +C
  66.  
  67.  
  68. -------------------------------------------------------------
  69. Cory Kempf                    EnigamI, Inc.
  70. cory@enigami.mv.com           ...!decvax!enigami!cory
  71. Annon:    wi.5036@wizvax.methuen.ma.us
  72.  
  73. "F' cryin' out loud, it's *your* life; shouldn't you at least examine 
  74. your lifestyle values to see if they are really what *you* want."
  75.                                         --Keith Lim
  76.