Path: utzoo!attcan!uunet!cs.utexas.edu!sun-barr!apple!darin From: darin@Apple.COM (Darin Adler) Newsgroups: comp.sys.mac.programmer Subject: Re: WaitNextEvent problem(actually "sleep") Keywords: WaitNextEvent MultiFinder SystemTask Message-ID: <1850@internal.Apple.COM> Date: 13 May 89 03:38:48 GMT References: <2864@crete.cs.glasgow.ac.uk> <520@biar.UUCP> <1643@internal.Apple.COM> <5781@brunix.UUCP> Organization: Apple Lines: 26 In article <5781@brunix.UUCP> omh@zaphod.UUCP (Owen M. Hartnett) writes: > Does anyone have any idea of what to pass for sleep? Most code I've seen uses > the GetDblTime call, but without explanation as to why this is (or isn't) good The best value to pass for sleep is the number of ticks until you will need to do something. For an application which does nothing in the background, the correct value is something huge (like MAXLONGINT in Pascal). For an application which is currently frontmost (keeping track as in the MultiFinder Programmer's Guide), which is only using idle time to flash the insertion point, an appropriate value is GetCaretTime. This will give your application time just often enough to flash it. If you are in the background and want to do background processing, almost any value will due. Larger values will result in larger intervals between the times you get background time. Even using values as small as 1 or 2 would be acceptable, especially if you used extremely large values when not doing anything. The most important this is that you don't get time that you use doing nothing and calling WaitNextEvent again. To do this effectively, you should use both sleep and mouseRgn. The Sample and TESample programs from DTS are good examples for this stuff. -- Darin Adler, System Software Scapegoat, Apple Computer Internet: darin@Apple.com UUCP: {nsc,sun}!apple!darin