Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!uwm.edu!psuvax1!swatsun!jackiw From: jackiw@cs.swarthmore.edu (Nick Jackiw) Newsgroups: comp.sys.mac.programmer Subject: Re: Background MAGIC (and I don't mean multifinder!!) Message-ID: <8JTNK0C@cs.swarthmore.edu> Date: 10 Aug 90 14:18:16 GMT References: <1990Aug9.203803.13885@ecn.purdue.edu> Reply-To: jackiw@cs.swarthmore.edu (Nick Jackiw) Organization: Visual Geometry Project, Swarthmore College, PA Lines: 54 Sorry about that blank posting--MacIP trashed my window and I was typing blind. moyman@ecn.purdue.edu (James M Moya) writes: > How is it that cdev/INIT's like Moire and SuperClock (and many others) can > run in the background whether multifinder is running or not!! I have been > checking every mac bnook I know of to learn of this black magic...NOTHING. > > Exactly what is it they are doing?? Or does anybody *really* know... Multifinder only schedules applications, and thus has nothing to do with init/cdevs. Instead, these programs install their code (usually into the system heap) while their INIT section is running. Then, they alter the system environment somewhat so that their code gets called periodically. The two most popular ways of doing this are by patching a trap which you can count on all applications calling frequently (e. g. SystemTask) or which is relevant to your particular task (e. g. MenuSelect, if your init/cdev dynamically altered application menus), or by installing an interrupt handler which is invoked by the vertical blanking interval interrupt. When either the trap is called or the VBL fires, the code they've loaded into the system heap is executed, allowing them to, say, check whether User's been idle for the predetermined time (Moire) or whether the clock has ticked (Superclock). > > > > I have an "appletalk" listener I am writing (cdev/INIT) that I want to come > > forward with a dialog when it recieves a particular packet...This should > > work whether Multi is running or not...I haven't been able to find > > *anything* in IM or any other book for that matter...I am frazzled at > > this point...Anybody with some insight to help a man on the brink... There are problems inherent in forcing your own dialog from out of the wood- work on some foreground application. What if, for example, that application hasn't called _InitDialogs, which must be done before any dialog manager use? (There are many other problems, too.) TechNote#184, and a chapter in Inside Mac#6, describe the Notification Manager, a built-in way for background applications and other "faceless code" (like an init/cdev) to issue a dialog which minimizes these compatibility problems. The dialog is pretty limited--you can have some canned text and only one button. However, this dialog can instruct the user to take some action which will allow you full and legal control over the interface, at which time you can put up anything you want. In your case, the Notification Manager would say something like "Whoa! My particular packet's here! Quick, open up my cdev." Note that this is how the Print Monitor works. > > Mike Moya -- -----Nicholas Jackiw [jackiw@cs.swarthmore.edu|jackiw@swarthmr.bitnet]----- "Here is how I built this artificial mine. I snatched a female louse from the hair of humanity. I was seen to lie with her on three successive nights, and then I flung her into the pit." _Maldoror_, Canto II