Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!husc6!rutgers!att!pegasus!ech From: ech@pegasus.ATT.COM (Edward C Horvath) Newsgroups: comp.sys.mac.programmer Subject: Re: ?? TSR in a Mac? If not DA. Message-ID: <2732@pegasus.ATT.COM> Date: 1 Apr 89 05:52:21 GMT References: <1474@ccnysci.UUCP> Distribution: comp.sys.mac.programmer Organization: AT&T ISL Middletown NJ USA Lines: 33 From article <1474@ccnysci.UUCP>, by cpyang@ccnysci.UUCP (Chao Ping Yang): ... > If I were still in the DOS world(I thought the Mac is > better so I switched), I could invoke a second > copy of the command processor so that I can do all > the DOS things while the data is collected in the background. > So the application Terminate & Stay Residence. > > Can somebody tells me how to do this in a Mac? In other words, > how do my application runs in the background so I can use the > Finder without using Multifinder? The simplest answer is to write a driver, either as a Desk Accessory or as a facility launched by a cdev (control panel item). The former typically have a window so that you can exercise control over them at any time, the latter remain in background and have to be summoned with the Control Panel DA. Of particular interest to you will be the accRun control call, which any driver (not just DAs) can sign up for. While there is no guarantee of how frequently you'll get the processor (only when the application calls SystemTask), you get control under "clean" conditions, with the whole toolbox and OS available. There are lots of restrictions with the use of a VBL task, since you can't do ANYTHING that may move or purge resources. The real drawback to using drivers is that you always enter and exit "through the top," i.e. you must retain any state information in explicit variables. This contrasts with the way of an application under Multifinder, which has its own stack and can relinquish control anytime, and without unrolling the stack, by calling WaitNextEvent (or GetNextEvent, or EventAvail). Hope that helps; see the Device Manager section of Inside Mac II for more info. =Ned Horvath=