Specifications
Apple II Technical Notes
4 of 4 #75: BeginUpdate Anomaly
Some consideration was given to posting an application event via the PostEvent call.
Unfortunately, there is a possibility that this application event will drop out of the queue not
handled. When the queue is full, the oldest event is dropped, and this could occur to application
events, which would be very bad in this case. Due to this possibility, posting an application event
refers to setting a global variable that is checked before the TaskMaster call in the main event
loop. This can be considered equivalent to posting an event via the PostEvent call.
So, the TaskMaster case would be as follows:
A. Dispose of the region created in Step 1.
B. Swap the updateRgn handle with the region handle created in Step 2.
C. Store the handle of the region created in Step 2 in a global variable named
eventUpdateRgn. Store the current window port in a global variable named
eventWindowPort.
D. Return to TaskMaster, which returns to the main event loop.
E. Immediately after the TaskMaster call in the main event loop, check the global
variable eventUpdateRgn. If it is not NULL then:
a. Copy the region into the updateRgn of the window eventWindowPort.
Using CopyRgn is the easiest way to copy the region. (Copying the region
posts an update event if the event UpdateRgn is not NULL.
b. Dispose of the region eventUpdateRgn, then set the variable
eventUpdateRgn to NULL, so that this “event” won’t be handled again.
Of course, the simplest way to handle all of this is to avoid situations where you have to take the
steps described above. If things like opening a window (or allowing the system to open one) and
InvalRect and InvalRgn can be avoided between calls to BeginUpdate and EndUpdate,
so can all of this ugliness.
Further Reference
• Apple IIGS Toolbox Reference, Volume 2










