Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!mnetor!uunet!husc6!hao!ames!amdahl!nsc!voder!apple!han
From: han@apple.UUCP (Byron Han)
Newsgroups: comp.sys.mac
Subject: MultiFinder programming tip
Message-ID: <6897@apple.UUCP>
Date: Fri, 4-Dec-87 12:42:37 EST
Article-I.D.: apple.6897
Posted: Fri Dec  4 12:42:37 1987
Date-Received: Wed, 9-Dec-87 05:39:08 EST
Organization: Apple Computer, Inc., Cupertino, USA
Lines: 32
Keywords: MultiFinder, Tip

A tip for MultiFinder friendly programming.

I have been tracking down a bug in a program which I am working on
for about 3 weeks.  I squashed it last night. 

Whenever you call GetNextEvent/WaitNextEvent, you should ALWAYS be
prepared to handle updates and also suspends/resumes.  ALWAYS.  

In otherwords, you may have a loop looking for keyDown's only::

WHILE GetNextEvent(keyDownMask, theEvent) DO BEGIN
	{blah blah blah}
END;

You should always use keyDownMask + updateMask at the very least,
and including app4Mask as well is desirable. 

If you do not include updateMask, you will "drop" update events which is 
unsightly confusing and bad.  If you do not include app4Mask, you will
drop suspend/resumes.  This is bad.  

And things bad will make the UITP be angry as well as the MPTP. :-) 
(User Interface Thought Police/Macintosh Programming Thought Police)
BTW:  the Thought Police references are purely in jest.  

Hope this helps someone.

-----
Byron Han - Apple Computer Inc - 20525 Mariani Ave MS 27Y - Cupertino, CA 95014
    "These are my opinions and views only.  Apple has nothing to do with them."
                         ATTNet: 408-973-1940  GENIE: BYRONHAN  APPLELINK: HAN1
                                UUCP: {sun, voder, nsc, mtxinu, dual}!apple!han