Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: Processes
Chapter 6 - Deferred Task Manager / Using the Deferred Task Manager


Defining a Deferred Task

You define a deferred task as a procedure taking no parameters and put the address of that procedure in the deferred task element whose address you pass to the DTInstall function. When your task is executed, register A1 contains the optional parameter that you put in the dtParm field of the task record.

If you write your deferred task in a high-level language, such as Pascal, you might need to retrieve the value loaded into register A1. The function GetA1 defined in Listing 6-3 returns the value of the A1 register.

Listing 6-3 Finding the value of the A1 register

FUNCTION GetA1: LongInt;
INLINE
   $2E89;         {MOVE.L A1,(SP)}
You can call GetA1 in your deferred task, as illustrated in Listing 6-4.

Listing 6-4 Defining a deferred task

PROCEDURE DoDeferredTask (dtParm: LongInt);
BEGIN
   {Your deferred task code goes here.}
END;

PROCEDURE MyDeferredTask;
VAR
   myParm:     LongInt;
BEGIN
   myParm := GetA1;        {retrieve parameter put in register A1}
   DoDeferredTask(myParm); {run the deferred task}
END;
Note that MyDeferredTask calls GetA1 to retrieve the parameter passed in the register A1. Then MyDeferredTask calls the application-defined procedure DoDeferredTask, passing it that parameter. The DoDeferredTask procedure does the real work of the deferred task. (This division into two routines is necessary to prevent problems caused by some optimizing compilers.)


Previous Book Contents Book Index Next

© Apple Computer, Inc.
17 JUN 1996